全局节点模块未正确安装.没有找到指令 [英] Global Node modules not installing correctly. Command not found
问题描述
我在安装全局节点模块时遇到问题,我在网上找到的所有内容都说解决方法只是添加-g.这不是问题.我认为这是链接问题或错误的目录问题.
I am having a problem installing global node modules and everything I find online says the solve is just adding -g. Which is not the problem. I believe it's a linking issue or wrong directory issue.
这是我的工作:
$ 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
但是,当我运行直接链接位置来表示它有效时:
However when I run the direct link location to express it works:
$ /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中有:
In my .bash_profile I have:
export PATH=/usr/local/bin:$PATH
export NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node
我需要更改Node环境才能下载到正确的文件夹吗?链接不正确吗?我迷路了.
Do I need to change my Node environment to download to correct folder? Is something not linking correctly? I am lost..
谢谢!
其他规格:
$ node --version
v0.8.20
$ npm --version
1.2.11
$ brew --version
0.9.4
OSX Version 10.8.2
推荐答案
在PATH
中添加/usr/local/share/npm/bin
(例如,在.bashrc
中).
Add /usr/local/share/npm/bin
to your PATH
(e.g., in .bashrc
).
有关更多信息,请参见npm help npm
:
For more info, see npm help npm
:
全局模式: npm将软件包安装到位于prefix/lib/node_modules的安装前缀中,并将bins安装在prefix/bin中.
global mode: npm installs packages into the install prefix at prefix/lib/node_modules and bins are installed in prefix/bin.
您可以使用npm get prefix
或npm config list | grep prefix
找到安装前缀.
You can find the install prefix with npm get prefix
or npm config list | grep prefix
.
这篇关于全局节点模块未正确安装.没有找到指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!