Node.js Express 模块未正确加载
Geos-Mac:hone georgiana$ npm list
/Users/georgiana/local/hone
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
└── [email protected]
的简单脚本
var express = require( 'express' ).createServer();
包含给出
Error: Cannot find module 'express'
at Function._resolveFilename (module.js:322:11)
.........
然而,当尝试使用express时,
。请注意这一点
Geos-Mac:hone georgiana$ npm express -v
1.0.6
,
Geos-Mac:hone georgiana$ node -v
v0.5.0-pre
有什么想法吗?
Geos-Mac:hone georgiana$ npm list
/Users/georgiana/local/hone
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
└── [email protected]
However, a simple script that contains
var express = require( 'express' ).createServer();
gives
Error: Cannot find module 'express'
at Function._resolveFilename (module.js:322:11)
.........
when trying to use express.
Please note that
Geos-Mac:hone georgiana$ npm express -v
1.0.6
and
Geos-Mac:hone georgiana$ node -v
v0.5.0-pre
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过在应用程序的文件夹中安装express模块来解决;受到手册的启发 http://nodejs.org/docs/v0.4.1 /api/modules.html#loading_from_node_modules_Folders
因此,在
/Users/georgiana/Sites/nodejs-play
中,我执行了npm installexpress
命令,该命令安装了模块位于/Users/georgiana/Sites/nodejs-play/node_modules/express
solved by installing the express module inside the application's folder; inspired by the manual http://nodejs.org/docs/v0.4.1/api/modules.html#loading_from_node_modules_Folders
so, inside
/Users/georgiana/Sites/nodejs-play
I executed thenpm install express
command, which installed the module in/Users/georgiana/Sites/nodejs-play/node_modules/express