【问题标题】:NPM install is not working [code 128]NPM 安装不工作 [代码 128]
【发布时间】:2018-04-11 06:59:46
【问题描述】:

NPM 不工作,给出权限被拒绝错误。这是完整的日志:

npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/jonschlinkert/resolve-file.git /root/.npm/_cacache/tmp/git-clone-8b5c9e7d
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-8b5c9e7d': Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-04-11T06_46_34_324Z-debug.log
root@ip-172-31-15-60:/var/www/html/itracker# npm install request
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/jonschlinkert/resolve-file.git /root/.npm/_cacache/tmp/git-clone-77c3de2c
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-77c3de2c': Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-04-11T06_47_05_916Z-debug.log

我尝试了什么:

  • 完全移除节点和 NPM 并安装。

    sudo chown -R $(whoami) ~/.npm

按照这里的答案:npm throws error without sudo

注意:

我尝试全局安装正在运行。但是在本地安装是行不通的。 我尝试了 sudo 和普通用户

【问题讨论】:

  • 试试 sudo npm install
  • @BasilBattikhi 我已经是 sudo 用户了。这就是为什么我一开始并不关心添加 sudo 的原因。但我试过了!
  • 你试过什么?
  • @BasilBattikhi sudo npm install
  • 问题现在解决了吗?

标签: javascript node.js ubuntu npm npm-install


【解决方案1】:

尝试sudo npm install,即使您正在使用 sudo 用户

【讨论】:

    【解决方案2】:

    使用最新的 npm

    npm install -g npm 
    

    【讨论】:

      猜你喜欢
      • 2016-05-03
      • 2016-01-12
      • 1970-01-01
      • 2014-12-06
      • 2022-08-23
      • 1970-01-01
      • 2019-08-20
      • 2015-11-03
      • 1970-01-01
      相关资源
      最近更新 更多