Comment update npm sur Windows?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment update npm sur Windows?

Message par ForumBot »

How can I update npm on Windows?




Source : Stack Overflow [windows]

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Comment update npm sur Windows?

Message par ayi »

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 running winget upgrade -q NodeJS or use chocolatey for that.


What method should I choose to update NPM?




  • Node.js v16 or higher?




  • npm install -g npm




  • Node.js v14 or below?




  • Consider updating to latest LTS release of Node.js




  • npm-windows-upgrade




Upgrade with npm-windows-upgrade


Run PowerShell en tant qu’administrateur


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.




  • Upgrades npm in-place, where Node.js installed it.




  • Does not modify the default path.




  • Does not change the default global package location.




  • Allows easy upgrades and downgrades and to install a specific version.




  • A list of versions matched between NPM and Node.js (https://nodejs.org/en/download/releases/) - but you will need to download the Node.js installer and run that to update Node.js (https://nodejs.org/en/)




Upgrade with npm


npm install -g npm


Note: some users still report issues updating npm with npm, but I haven’t had that experience with v16+.

Répondre

Revenir à « Performance & Dépannage »