eyeglass
eyeglass copied to clipboard
TypeError: Cannot read property 'eyeglass' of null
I was following the README's documentation for creating an eyeglass module but I keep running into this error. What am I doing wrong in my setup?
TypeError: Cannot read property 'eyeglass' of null
at getModuleName (/Library/WebServer/Documents/my-project/node_modules/eyeglass/lib/modules/EyeglassModule.js:95:43)
at new EyeglassModule (/Library/WebServer/Documents/my-project/node_modules/eyeglass/lib/modules/EyeglassModule.js:32:15)
at /Library/WebServer/Documents/my-project/node_modules/eyeglass/lib/modules/EyeglassModules.js:45:13
at Array.reduce (native)
at new EyeglassModules (/Library/WebServer/Documents/my-project/node_modules/eyeglass/lib/modules/EyeglassModules.js:44:39)
at new Eyeglass (/Library/WebServer/Documents/my-project/node_modules/eyeglass/lib/index.js:26:18)
at Eyeglass (/Library/WebServer/Documents/my-project/node_modules/eyeglass/lib/index.js:18:13)
at Gulp.<anonymous> (/Library/WebServer/Documents/my-project/Gulpfile.js:202:14)
at module.exports (/Library/WebServer/Documents/my-project/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Library/WebServer/Documents/my-project/node_modules/orchestrator/index.js:273:3)
Here's the content of the related files, let me know if I'm missing anything.
Gulpfile.js
gulp.task('sampleTask', function (cb) {
var sass = require('gulp-sass');
var eyeglass = require('eyeglass');
var sassOpts = {
eyeglass: {
modules: [
{
path: "my-module/"
}
]
}
};
pump([
gulp.src('sample.scss'),
sass(eyeglass(sassOpts)),
gulp.dest('.')
], cb);
});
my-module/eyeglass-exports.js
"use strict";
module.exports = function(eyeglass, sass) {
return {
functions: {
"hello($name)": function(name, done) {
done(sass.types.String("Hello, " + name.getValue()));
}
}
};
};
my-module/package.json
{
"name": "my-module",
"keywords": [
"eyeglass-module",
"sass"
],
"main": "eyeglass-exports.js",
"eyeglass": {
"exports": "eyeglass-exports.js",
"needs": "^1.1.2"
}
}
I don't believe we resolve pathnames here, so you should do something like path.join(__dirname, "my-module")
. If this doesn't work for you, you can try using the latest master of eyeglass which should throw a more meaning error, including the pathname it tried to use.
Ah hah! That solved the issue for me. Should this be added to the documentation or would eyeglass start resolving path names?