首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >成功安装npm后未定义手写笔

成功安装npm后未定义手写笔
EN

Stack Overflow用户
提问于 2013-12-04 21:36:54
回答 1查看 397关注 0票数 0

我试图跟随一个教程,学习一些关于node.js的知识。不过,我一直有个奇怪的错误。在npm install stylus之后,我得到了以下信息:

代码语言:javascript
复制
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

代码语言:javascript
复制
app.use(stylus.middleware(
{
    src: __dirname + '/public'
    , compile: compile
}
))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-04 21:38:04

npm install只是在磁盘上创建JS文件。

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

代码语言:javascript
复制
var stylus = require('stylus');
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20386526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档