如何将 npm(node.js 包管理器)添加到 PATH 中?
我像这样安装了node.js:
cd /usr/local/bin/
git clone --depth 1 http://github.com/joyent/node.git
cd node
git checkout origin/v0.4 # optional. Note that master is unstable.
export JOBS=2 # optional, sets number of parallel commands.
mkdir ~/local
./configure --prefix=$HOME/local/node
make
make install
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
source ~/.profile
然后我执行了这个curl http://npmjs.org/install.sh | sh 安装 npm。我注销并重新登录后,无法识别 npm 命令:
[/usr/local/bin/node]# npm install now
-bash: npm: command not found
我应该向 PATH 添加什么以使 npm 工作?
I installed node.js like this:
cd /usr/local/bin/
git clone --depth 1 http://github.com/joyent/node.git
cd node
git checkout origin/v0.4 # optional. Note that master is unstable.
export JOBS=2 # optional, sets number of parallel commands.
mkdir ~/local
./configure --prefix=$HOME/local/node
make
make install
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
source ~/.profile
Then I executed this curl http://npmjs.org/install.sh | sh
to install npm. After I logged out and logged back in, npm command wasn't recognized:
[/usr/local/bin/node]# npm install now
-bash: npm: command not found
What should I add to the PATH to have npm working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
该建议来自 https://github.com/isaacs/npm#readme。
它不像curl|sh那么可爱,但是很有效。
Try this:
That advice comes from of https://github.com/isaacs/npm#readme.
It is not as cute as curl|sh, but works.
好消息:npm 现在与 Nodejs 一起提供了!
Great news : npm now comes with nodejs !
我是初学者~但是希望对大家有所帮助。
我使用centos7,你知道yum吗(一个可以下载和安装类似mirosoft Windows的程序的工具)
首先,我在wiki.centos上搜索关键字“node.js”,我找到了这个。 https://wiki.centos.org/SpecialInterestGroup/SCLo /CollectionsList?highlight=%28node.js%29。
目前有两个版本的nodejs可以使用,我选择了较高的版本。
URL 为 https://www.softwarecollections.org/en/scls/ rhscl/rh-nodejs4/
命令行如下:
I am a beginner~, but I want be helpful.
I use centos7, and do you know yum (a tool could download and setup programs like mirosoft Windows)
First, I search keyword "node.js" at wiki.centos, I find this. https://wiki.centos.org/SpecialInterestGroup/SCLo/CollectionsList?highlight=%28node.js%29.
There are two versions of nodejs could be used at the moment, I chose the higher one.
the URL is https://www.softwarecollections.org/en/scls/rhscl/rh-nodejs4/
and the command lines are below: