简体   繁体   English

无法使用 npm update/upgrade -g 命令升级 NPM 包

[英]Can't upgrade NPM packages with npm update/upgrade -g command

Running Archlinux + Gnome-Shell 3.20, NodeJS 5.10.1 NPM 3.8.6 version.运行 Archlinux + Gnome-Shell 3.20,NodeJS 5.10.1 NPM 3.8.6 版本。

When running sudo npm update -g or sudo npm upgrade -g terminal gives运行sudo npm update -gsudo npm upgrade -g终端时给出

npm ERR! addLocal Could not install /build/semver/src/semver-5.1.0.tgz
npm ERR! addLocal Could not install /build/semver/src/semver-5.1.0.tgz
npm ERR! addLocal Could not install /build/uglify-js/src/uglify-js-2.6.2.tgz

Same output for sudo npm outdated -g sudo npm outdated -g相同输出

While running sudo npm install -g <package_name> "updates" package no problem.运行sudo npm install -g <package_name> "updates" package 没问题。 Of course, I could install/upgrade each package individually but that defeats the purpose of npm update/upgrade -g command.当然,我可以单独安装/升级每个包,但这违背了 npm update/upgrade -g 命令的目的。

I've updated NPM to latest version via sudo npm install -g npm@latest in hopes it would fix the issue like for many here https://github.com/npm/npm/issues/10165 but to no avail.我已经通过sudo npm install -g npm@latest将 NPM 更新到最新版本,希望它能解决这里的许多问题https://github.com/npm/npm/issues/10165但无济于事。

There are a few things that could be wrong, and this should help resolve your problem.有一些事情可能是错误的,这应该有助于解决您的问题。

  1. You should fix your npm permissions , so you don't have to use sudo when you attempt to install a package globally using npm.您应该 修复您的 npm 权限,因此当您尝试使用 npm 全局安装软件包时,您不必使用sudo

  2. nvm is a tool that should be able to help you. nvm是一个应该能够帮助你的工具。 There is likely an bug/corruption in your current node/npm version by looking at the GitHub issue, and the tool nvm will make it possible to change node versions while also fixing your sudo issue.通过查看 GitHub 问题,您当前的节点/npm 版本中可能存在错误/损坏,并且 nvm 工具可以在更改节点版本的同时修复您的sudo问题。

It is also possible that you installed npm using pacman rather than npm which could be why you can't upgrade correctly.也有可能您使用 pacman 而不是 npm 安装了 npm,这可能是您无法正确升级的原因。 You could the latest version of npm by using the command pacman -S npm which is a package available in the community repository.您可以使用命令pacman -S npm来获取最新版本的 npm,该命令是社区存储库中提供的一个包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM