【问题标题】:Stylus Not Defined After Successful npm install成功 npm 安装后未定义手写笔
【发布时间】:2013-12-04 21:36:54
【问题描述】:

我正在尝试按照教程学习一些关于 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
}
))

【问题讨论】:

    标签: javascript node.js stylus


    【解决方案1】:

    npm install 只需在磁盘上创建 JS 文件即可。

    你仍然需要调用require()来加载文件并创建一个局部变量:

    var stylus = require('stylus');
    

    【讨论】:

    • 嘎。我有 var stylue = require('stylus') 并没有抓住它。问题已解决,谢谢!
    猜你喜欢
    • 2018-08-08
    • 2017-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-07
    • 1970-01-01
    • 2014-05-30
    相关资源
    最近更新 更多