I'm attempting to follow along with a tutorial and learn a bit about node.js. I keep getting a weird error, though. After npm install stylus, I get this:

npm http GET https://registry.npmjs.org/stylus
npm http 304 https://registry.npmjs.org/stylus
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/
npm http GET https://registry.npmjs.org/cssom
npm http GET https://registry.npmjs.org/sax
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/cssom
npm http 304 https://registry.npmjs.org/sax
stylus@0.41.0 node_modules/stylus
├── debug@0.7.4
├── mkdirp@0.3.5
├── cssom@0.2.5
└── sax@0.5.5

No errors, nothing warning me of the world's end, not even any red text. Then when I try to run the application node app.js I get ReferenceError: stylus is not defined on this line:

app.use(stylus.middleware(
{
    src: __dirname + '/public'
    , compile: compile
}
))
有帮助吗?

解决方案

npm install just create JS files on disk.

You still need to call require() to load the file and create a local variable:

var stylus = require('stylus');
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top