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

发布于 2024-11-17 00:27:21 字数 623 浏览 2 评论 0原文

我像这样安装了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

〗斷ホ乔殘χμё〖 2024-11-24 00:27:21

试试这个:

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

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

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

Try this:

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

That advice comes from of https://github.com/isaacs/npm#readme.

It is not as cute as curl|sh, but works.

〆一缕阳光ご 2024-11-24 00:27:21

好消息:npm 现在与 Nodejs 一起提供了!

Great news : npm now comes with nodejs !

残花月 2024-11-24 00:27:21

我是初学者~但是希望对大家有所帮助。

我使用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

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:

# 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文