Mark Mark - 1 year ago 424
Node.js Question

sudo: npm: command not found

I'm trying to upgrade to latest version of node. Im falling the instructions at

But when I do:

sudo npm install -g n

I get the error:

sudo: npm: command not found

npm works without sudo. When i do:

whereis node

I see:

node: /usr/bin/node /usr/lib/node /usr/bin/X11/node /usr/local/node

When i run:

which npm



I tried the solution at

But i'm still getting the same error. I also looked at the /etc/sudoers file and the relevant line is:

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

This looks fine to me. How can I possibly get NPM working with sudo command?

Answer Source

The npm file should be in usr/local/bin/npm. If it's not there, install node.js again with the package on their website. This worked in my case.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download