2

I tried to remove NPM and Node and reinstall them both. I'm a complete noob in the process as you'll notice.

I sadly can't remember the commands I used.

After I removed them, I ran node -v and it returned command not found and I ran npm -v and it returned command not found, so I thought the process was successful.

I then went to Nodejs website and downloaded the latest package for MacOS (v12.11.1) and ran the install. It said it was successful. I check node -v and it returned 12.11.1, as expected, but then I checked npm -v and it sadly returned npm not a command!!

enter image description here

If I run which node I get /usr/local/bin/node. If I run which npm I get nothing returned.

I've since tried lots of ways of removing them both again just in case something was missed but I get the same thing every time - no NPM!

Most of the answers on StackOverflow talk about Brew but I have not used Brew and I have tried so many of the other answers but just can't get NPM back.

The PKG installer mentions this: 'Make sure that /usr/local/bin is in your $PATH.' but not entirely sure what that means and if that's my problem or not.

Does anybody know a surefire way to remove all traces of both, so when I reinstall the PKG from Node, I get both Node and NPM installed and working correctly?

UPDATE:

I seem to have had some success since posting this question. I followed instructions at https://docs.npmjs.com/misc/removing-npm.html to manually remove 'everything NPM-rleated' and ran the installer again. Now when I check npm -v it returns to the latest version number 6.11.3.

I will test things a bit more before deleting/answering my own question.

3 Answers 3

2

To fix this problem I ran the following command as suggested by NPM:

To remove everything npm-related manually:

rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*

All was OK after I reinstalled Node and checked NPM's version using npm -v.

Sign up to request clarification or add additional context in comments.

Comments

0

Googling 'Adding to $PATH mac' returns this as the top result:

https://www.architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/

Open up Terminal and run the following command:

sudo nano /etc/paths

Enter your password, when prompted.

Go to the bottom of the file, and enter the path you wish to add.

Hit control-x to quit.

Enter “Y” to save the modified buffer.

That’s it! To test it, in new terminal window, type:

echo $PATH

Comments

-1

this is what I did on mac

rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
brew uninstall node
brew install node

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.