When NPM is broken on Windows

Published by Berkan K. on November 30

book 3 min read

So, have you ever broke your NPM or Node? I did, and it was a pain to fix it. But here is how a fully cleaned install of NPM and Node on Windows looks like.

Uninstalling NPM and Node

  1. Uninstall node from Programs & Features with the uninstaller.

  2. Remove all the shortcuts like on task managers/ desktop etc

  3. Remove all the folder given below

C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users\{User}\AppData\Roaming\npm (or %appdata%\npm)
C:\Users\{User}\AppData\Roaming\npm-cache (or %appdata%\npm-cache)
C:\Users\{User}\.npmrc (and possibly check for that without the . prefix too)
  1. Remove from the environment variable via checking Path value

  2. Open your command prompt try to run below command

where node 

If it will show directories then delete all the directories

  1. Reboot your system

  2. Go to the node js side download or directly install the node from there

Installing NPM and Node

After you have uninstalled NPM and Node, you can install them again from NodeJS Official Website. Here, we are choosing the 64-bit version of the Node.js installer.

Step 1 The LTS (Long-term Support) version is the recommended version for most users. It’s the version that is most stable and most widely used. The Current version is the most recent version of Node.js. It will have the newest features, but it might also have some bugs (you probably already know that).

The installer will download to your default download location. Once the download is complete, open the installer to begin the installation process.

Step 2

You will get a welcome message on the screen. Click on the Next button to continue.

  • Choose the desired path where you want to install Node.js.
Step 3
  • By clicking on the Next button, you will get a custom page setup on the screen. Make sure you choose npm package manager, not the default of Node.js runtime. This way, we can install Node and NPM simultaneously.

The following features will be installed by default:

  • Node.js runtime
  • Npm package manager
  • Online documentation shortcuts
  • Add to Path
Step 4

By now the setup is ready to install. Click on the Install button to start the installation process.

Step 5

If you have a doubt whether you have installed everything correctly or not, let’s verify it with “Command Prompt”.

node -v

and then check for npm

npm -v

And that’s it! With these steps, I turned a frustrating situation into a smooth and successful reinstallation of NPM and Node on my Windows machine.

NPM Logo
Hello, I'm a 23-year-old Software Engineer based in Denmark, specializing in Cybersecurity and
Fullstack Development.

Beyond programming, I enjoy sharing my journey and insights through writing, aiming to contribute to the tech community and inspire like-minded professionals.

Post Details Category