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
然而,一个包含 的简单脚本
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
有什么想法吗?
npm
将模块本地安装。因此您的代码需要位于/.node_modules/
文件夹附近。 - Raynos> require.paths [ '/Users/georgiana/.node_modules', '/Users/georgiana/.node_libraries', '/Users/georgiana/local/hone/lib/node' ]
> Geos-Mac:node_modules georgiana$ pwd
/Users/georgiana/local/hone/node_modules
Geos-Mac:node_modules georgiana$ ls -lsa
total 0
0 drwxr-xr-x 5 georgiana staff 170 May 21 13:55 .
0 drwxr-xr-x 7 georgiana staff 238 May 21 13:54 ..
0 drwxr-xr-x 2 georgiana staff 68 May 21 13:55 .bin
0 drwxr-xr-x 9 georgiana staff 306 May 21 01:01 gently
0 drwxr-xr-x 13 georgiana staff 442 May 21 01:01 mysql
- Georgiana/Users/georgiana/Sites/nodejs-play
目录下执行了npm install express
命令,该命令将模块安装在/Users/georgiana/Sites/nodejs-play/node_modules/express
目录下。 - Georgiana