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

时间:2011-06-22 11:26:36

标签: node.js centos cpanel whm

我安装了这样的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正常工作?

3 个答案:

答案 0 :(得分:17)

试试这个:

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

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

它不像卷曲那样可爱,但有效。

答案 1 :(得分:2)

好消息:现在npm现在有了nodejs!

答案 2 :(得分:0)

我是初学者〜,但我想要帮助。

我使用centos7,你知道yum(一个工具可以下载和安装像mirosoft Windows这样的程序)

首先,我搜索关键字" node.js"在wiki.centos,我发现了这个。 https://wiki.centos.org/SpecialInterestGroup/SCLo/CollectionsList?highlight=%28node.js%29。 目前可以使用两个版本的nodejs,我选择了较高版本。 网址为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