0

I know this is a noob question but I just start learning to code. I don't know why I cannot upgrade the current version of npm in my computer (5.5.1) to the newer one (8.1.2). Can someone please help me with this?

enter image description here

enter image description here

Mofi
  • 46,139
  • 17
  • 80
  • 143
  • Normally when you install Node, you get a compatible version of NPM as well. It seems that didn't happen for you. Try re-installing Node by completely removing any previous installations first – Phil Mar 25 '22 at 03:59
  • I did try that for two times and it just did not work – Alex Nguyen Mar 25 '22 at 04:02
  • How are you installing Node? Looks like you might have an older NPM binary still in your `PATH` that needs purging. – Phil Mar 25 '22 at 04:07
  • I tried to downgrade it for my online course, but I encountered some problems along the way so I'm trying to get things back to normal – Alex Nguyen Mar 25 '22 at 04:07
  • I tried to edit the path in environmental variables as well. – Alex Nguyen Mar 25 '22 at 04:08
  • just added an answer that may help with this. Installing `n` lets you have multiple node versions. If you are doing an online course based on an older version, switch to that version using `n` – chris Mar 25 '22 at 04:09
  • I went for this "C:\Users\ADMIN\AppData\Roaming\npm" instead of "C:\Program Files\nodejs" – Alex Nguyen Mar 25 '22 at 04:09
  • 1
    Does this answer your question? [How can I update NodeJS and NPM to their latest versions?](https://stackoverflow.com/questions/6237295/how-can-i-update-nodejs-and-npm-to-their-latest-versions) – JΛYDΞV Mar 25 '22 at 05:37

1 Answers1

1

There are couple of solutions I can think of:

Solution #1

Uninstall Node.js from your computer and install again. As the error message says, "use the version of npm that is bundled with Node.js". This is the preferred solution and very straightforward. Unless... you want to keep multiple versions of node in your computer, if that is the case, solution #2 will help.

Solution #2

Install a Node version manager (such as n). The package n allows you to download multiple versions of Node.js in your computer and switch between then when needed.


If the issue persists, you may have conflicting versions or directories in your computer. Please read this post about How to completely remove node.js from Windows. Then try re-installing from the website once you are done removing Node.

chris
  • 2,490
  • 4
  • 32
  • 56
  • Thank you! I resolved the question! Deleting nodejs completely from my computer is a little bit confusing. However, I don't know why I have to remove the npm and npm-cache folders in both "C:\Users\ADMIN\AppData\Roaming\npm" in order for it to work. – Alex Nguyen Mar 25 '22 at 04:18