我在安装全局节点模块时遇到问题,我在网上找到的所有内容都说解决方法只是添加-g。这不是问题。我认为这是链接问题或错误的目录问题。
这是我的工作:
$ npm install -g express
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.3
...downloads correctly
$ express myapp
bash: express: command not found
但是,当我运行直接链接位置来表示它有效时:
$ /usr/local/share/npm/bin/express myapp
create : myapp
create : myapp/package.json
create : myapp/app.js
... Builds app correctly
模块在哪里:
$ which node
/usr/local/bin/node
$ node -pe process.execPath
/usr/local/Cellar/node/0.8.20/bin/node
$ npm link express
/Users/bentonrr/Development/Personal/node_modules/express -> /usr/local/share/npm/lib/node_modules/express
在我的.bash_profile中,我有:
export PATH=/usr/local/bin:$PATH
export NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node
我需要更改Node环境才能下载到正确的文件夹吗?链接不正确吗?我迷路了..
谢谢!
其他规格:
$ node --version
v0.8.20
$ npm --version
1.2.11
$ brew --version
0.9.4
OSX Version 10.8.2
express
。