如何在 Windows 上更新 npm? [英] How can I update npm on Windows?

查看:29
本文介绍了如何在 Windows 上更新 npm?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这个:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

...但它没有用.

如何在 Windows 上执行此操作?

How do I do this on Windows?

推荐答案

这是 在 Windows 上升级 npm.

以管理员身份运行 PowerShell

Run PowerShell as Administrator

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade

注意:不要运行npm i -g npm.而是使用 npm-windows-upgrade 来更新 npm.此外,如果您运行 NodeJS 安装程序,它将替换节点版本.

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.

  • 就地升级 npm,节点安装它的位置.
  • 轻松更新,通过运行 npm-windows-upgrade -p -v latest 更新到最新版本.
  • 不修改默认路径.
  • 不会更改默认的全局包位置.
  • 允许轻松升级和降级.
  • NPM 和 NODE 之间匹配的版本列表(https://nodejs.org/en/download/releases/) - 但你需要下载 NODE INSTALLER 并运行它来更新节点 (https://nodejs.org/en/)
  • 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.
  • A list of versions matched between NPM and NODE (https://nodejs.org/en/download/releases/) - but you will need to download NODE INSTALLER and run that to update node (https://nodejs.org/en/)

这篇关于如何在 Windows 上更新 npm?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆