我试图跟随一个教程,学习一些关于node.js的知识。不过,我一直有个奇怪的错误。在npm install stylus之后,我得到了以下信息:
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没有错误,没有警告我世界末日,甚至没有任何红色的文字。然后,当我尝试运行应用程序node app.js时,我在这一行中得到了ReferenceError: stylus is not defined:
app.use(stylus.middleware(
{
src: __dirname + '/public'
, compile: compile
}
))发布于 2013-12-04 21:38:04
npm install只是在磁盘上创建JS文件。
您仍然需要调用require()来加载文件并创建一个局部变量:
var stylus = require('stylus');https://stackoverflow.com/questions/20386526
复制相似问题