【问题标题】:Why am I getting an error when installing the latest version of npm?为什么在安装最新版本的 npm 时出现错误?
【发布时间】:2021-06-24 16:41:00
【问题描述】:

我当前的 npm 版本是 3.5.2。我想更新 npm 和 sudo npm install npm @ latest -g 我正在输入这个命令。我尝试删除 package.json 但我在下面收到此错误。

【问题讨论】:

  • 这真的很难读。请张贴实际文字。

标签: ubuntu npm npm-install


【解决方案1】:

我今天遇到了类似的问题。没有任何效果,我发现了很多类似问题的错误报告。解决方案是use a version manager like nvm

(可选)如果您运行的是 Ubuntu,您可以删除当前安装的系统范围版本的 nodejsnpm,如下所示:

sudo apt remove nodejs npm

以下是我输入的在我的用户目录中安装新版本的确切命令。结果,所有权限问题都消失了。这些命令可能适用于所有操作系统,只需稍作改动:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
source ~/.bashrc  # this line might change
nvm install v15.12.0
npm install -g npm@7.7.5

如果您有 Mac,请改用source ~/.bash_profile。 ...除非您正在运行 zsh,在这种情况下您需要 source ~/.zshrc。如果一切都失败了,source ~/.profile

For more info

【讨论】:

    猜你喜欢
    • 2016-10-13
    • 2022-06-26
    • 2021-11-23
    • 2014-03-03
    • 1970-01-01
    • 2016-10-01
    • 2013-02-19
    • 2020-03-25
    相关资源
    最近更新 更多