繁体   English   中英

如何将npm(node.js包管理器)添加到PATH?

[英]How can I add npm (node.js package manager) to the 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 curl http://npmjs.org/install.sh | sh安装npm。 我退出并重新登录后,无法识别npm命令:

[/usr/local/bin/node]# npm install now
-bash: npm: command not found

我应该在PATH中添加什么才能让npm正常工作?

试试这个:

git clone https://github.com/npm/cli
cd npm/cli
sudo make install

该建议来自https://github.com/isaacs/npm#readme

它不像curl | sh那么可爱,但是有效。

好消息:npm现在配有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/ ,命令行如下:

# Install a package with repository for your system:
# On CentOS, install package centos-release-scl available in CentOS repository:
$ sudo yum install centos-release-scl-rh

# On RHEL, enable RHSCL repository for you system:
$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms

# 2. Install the collection:
$ sudo yum install rh-nodejs4

# 3. Start using software collections:
$ scl enable rh-nodejs4 bash

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM