How can I add npm (node.js package manager) to the PATH?

I installed node.js like this:

cd /usr/local/bin/
git clone --depth 1
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 install
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
source ~/.profile

Then I executed this curl | 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?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Try this:

git clone
cd npm/cli
sudo make install

That advice comes from of

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

Solution 2

Great news : npm now comes with nodejs !

Solution 3

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.
There are two versions of nodejs could be used at the moment, I chose the higher one.
the URL is
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

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply