sudo npm command not found

0 votes
While using the latest version of node, 

sudo npm install -g n

I get the error:

sudo: npm: command not found

npm works without sudo when I use:

whereis node


I see:

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


Running:

which npm


Shows:

/usr/local/node/bin/npm


I have still been 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 the sudo command?

Feb 17 in Others by Soham
• 8,730 points
537 views

1 answer to this question.

0 votes

To answer your question, for me, the following line helped me:-

sudo apt-get install npm

answered Feb 17 by Aditya
• 7,280 points

Related Questions In Others

0 votes
1 answer

'npm' is not recognized as internal or external command, operable program or batch file

To your existing lines of code, include ...READ MORE

answered Feb 10 in Others by Rahul
• 8,980 points
2,562 views
0 votes
1 answer

'git rev-parse HEAD' is not recognized as an internal or external command

Hi@akhtar, I also faced the same problem. You ...READ MORE

answered Jul 17, 2020 in Others by MD
• 95,360 points
1,731 views
0 votes
0 answers
0 votes
0 answers

Unix xxd -r -p command NodeJS equivalent

I'm attempting to convert an encrypted shell ...READ MORE

Jun 9 in Node-js by Vaani
• 7,020 points
24 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
972 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP