TypeError: Cannot read property 'eyeglass' of null
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 738
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
I was following the README's documentation for [creating an eyeglass module](https://github.com/sass-eyeglass/eyeglass#writing-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. (/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**
```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**
```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**
```json
{
"name": "my-module",
"keywords": [
"eyeglass-module",
"sass"
],
"main": "eyeglass-exports.js",
"eyeglass": {
"exports": "eyeglass-exports.js",
"needs": "^1.1.2"
}
}
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with eyeglass/lib/modules/EyeglassModule.js at getModuleName, then trace how the module path in Gulpfile.js is loaded. Compare my-module/package.json and eyeglass-exports.js with the README's module format and reproduce the reported stack trace. Done means the setup either works or the documentation and error handling clearly identify the required configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, sass
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100