0

when I tried

npm install -g npm

there were a lot of warnings

so I did

sudo npm install -g npm

which seemed to work flawlessly.

however now, when I want to use npm in terminal it returns:

bash: npm: command not found

I can only use npm with sudo now.

How do I revert this?

I tried reinstalling npm and nodejs but it does not work.

I am running arch linux btw

user1557314
  • 169
  • 3
  • 14
  • Does this answer your question? [npm throws error without sudo](https://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo) – Aris Feb 20 '21 at 10:53

3 Answers3

0

try sudo apt install npm.

Not sure. But it may work.

0

Probably its a permission issue.( note this is a hack which might lead to security issue)

try doing this first

sudo chown -R $(whoami) ~/.npm

if the above doesn't work try this

sudo chown -R $(whoami) /usr/local/lib/node_modules
sudo chown -R $(whoami) /usr/local/bin
sudo chown -R $(whoami) /usr/local/share

a better and solution to this problem is this answer https://stackoverflow.com/a/41395398/13126651

Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67
0

I would suggest you to first uninstall Node and npm. Then install the NVM. In this way, you'll not face the permission issue and at the same time you can have multiple version of Node (if needed). Once you have NVM on your system you can use following command to install latest version of Node.

nvm install node
Viral Patel
  • 1,104
  • 4
  • 7