node.js express module not loading properly

余生长醉 提交于 2020-01-02 05:22:17

问题


Geos-Mac:hone georgiana$ npm list
/Users/georgiana/local/hone
├─┬ express@2.3.6 
│ ├── connect@1.4.1 
│ ├── mime@1.2.2 
│ └── qs@0.1.0 
├── gently@0.9.0 
└── mysql@0.9.1

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?


回答1:


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 the npm install express command, which installed the module in /Users/georgiana/Sites/nodejs-play/node_modules/express



来源:https://stackoverflow.com/questions/6081488/node-js-express-module-not-loading-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!