I tried this:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
…but it didn’t work.
How do I do this on Windows?
I tried this:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
…but it didn’t work.
How do I do this on Windows?
Note: The question is specifically asking how to upgrade npm, not Node.js. If you want to update Node.js over a CLI on windows, I recommend using chocolatey for that.
npm install -g npm
npm-windows-upgrade
Run PowerShell as Administrator
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
Note: if you run the Node.js installer, it will replace the Node.js version.
npm install -g npm
Note: some users still report issues updating npm with npm, but I haven’t had that experience with v16+.