Skip to content

Instantly share code, notes, and snippets.

@anchal20
Last active January 17, 2017 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anchal20/55ac1121feb1c49642d4fd1883707db0 to your computer and use it in GitHub Desktop.
Save anchal20/55ac1121feb1c49642d4fd1883707db0 to your computer and use it in GitHub Desktop.
I had lot of issue while reinstalling node/npm. After lot of googling I came across the solution which worked for me. This Gist iterates the steps to remove node and npm completely from the system.

When I upgraded my node to 7+ and npm to 4+ I started facing problem while running 'npm install'. It was throwing error ‘Cannot find module 'internal/fs'’. I googled a lot and found out that my node/npm versions were unsupportive of certain modules. I tried to change the version but nothing happened. Then i tried running ‘Gulp’ which I was using in my app for module bundling. To my surprise it said ‘zsh: command not found: gulp’.

Now I thought, the only way to get rid of these problems to re-install node/npm again. I did ‘brew uninstall node’ and still node -v -> v7.4.0 This was frustrating!!!

I googled to see if there is another one line code by Node to uninstall it, but could’nt find anything. Then I read somewhere on the web that I have to remove node from all possible places and only then I will be assured that its been uninstalled.

Below are the steps that you should follow to uninstall node/npm and then re-install it.

Goto /usr/local/bin and delete any node, node_modules

  • sudo rm -rf node
  • sudo rm -rf node_modules

Now goto /usr/local/include and repeat the above process

  • sudo rm -rf node
  • sudo rm -rf node_modules

Now check your home directory and remove node, node_modules or ay node executables from anywhere you find it. Check local, lib, include, bin folder. ANYWHERE you find it!

  • sudo rm -rf /usr/local/bin/npm

If you have installed node via brew(as I didn’t remember if I had used brew to install node, therefore to be on the safer side I ran this command as well), then run

  • Brew uninstall node

Do some additional deletions for additional safety

  • sudo rm -rf /usr/local/share/man/man1/node.1
  • sudo rm -rf /usr/local/lib/dtrace/node.d
  • sudo rm -rf ~/.npm

This removes all node/npm from your system, now you can reinstall node. I installed from the node website by downloading the package. You can also install using brew - brew install node.

You can check the version of node and npm installed by

  • node -v
  • npm -v

Now ‘npm install’ ran smoothly and after installing gulp globally I was able to work again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment