9

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

4

3 回答 3

17

尝试这个:

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

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

它不像 curl|sh 那样可爱,但很有效。

于 2011-06-22T13:33:41.940 回答
2

好消息:npm 现在带有 nodejs !

于 2013-01-28T08:18:19.003 回答
0

我是初学者〜,但我想对您有所帮助。

我用的是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
于 2017-06-22T03:06:04.170 回答