admin管理员组文章数量:1311005
I am looking for a way to upgrade my npm, I follow the option 3 for windows in here npm docs. but when I install it it said npm.exe already in nodejs folder. I try to overwrite it with --force but it still not overwritten. How to do it correctly? also how to update node?
I am looking for a way to upgrade my npm, I follow the option 3 for windows in here npm docs. but when I install it it said npm.exe already in nodejs folder. I try to overwrite it with --force but it still not overwritten. How to do it correctly? also how to update node?
Share Improve this question edited Jul 28, 2020 at 11:41 Farhan Khalifa asked Jul 28, 2020 at 11:29 Farhan KhalifaFarhan Khalifa 331 gold badge1 silver badge8 bronze badges 7- Install latest node.js – Adam Orłowski Commented Jul 28, 2020 at 11:31
- yes i already have it – Farhan Khalifa Commented Jul 28, 2020 at 11:31
-
Doesn’t
npm i-g npm
work? – evolutionxbox Commented Jul 28, 2020 at 11:31 - Then what is the problem? – Adam Orłowski Commented Jul 28, 2020 at 11:32
- You should look at nvm for windows and let that manage your npm and node versions. Much easier for upgrading and switching – Enslev Commented Jul 28, 2020 at 11:33
4 Answers
Reset to default 8This is the new best way to upgrade npm on Windows.
Run PowerShell as Administrator
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
Note: Do not run npm i -g npm
. Instead, use npm-windows-upgrade
to update npm going forward. Also if you run the NodeJS installer, it will replace the node version.
- Upgrades npm in-place, where node installed it.
- Easy updating, update to the latest by running
npm-windows-upgrade -p -v latest
. - Does not modify the default path.
- Does not change the default global package location.
- Allows easy upgrades and downgrades.
- Officially remended by the NPM team.
- A list of versions matched between NPM and NODE (https://nodejs/en/download/releases/) - but you will need to download NODE INSTALLER and run that to update node (https://nodejs/en/)
There is a tool, nvm, that solves your problem quite easly. There is also a Windows version, is not as cool as the linux/mac version but it works fine anyway
I suggest using option 1. Go to environment system variables and add "%appdata%\npm" to path like this: edit path
Then updated npm files should be loaded before those you installed with node
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
本文标签: javascriptHow to update npm in windowsStack Overflow
版权声明:本文标题:javascript - How to update npm in windows? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741820084a2399309.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论