NPM安装无法正常工作[代码128]

时间:2018-04-11 06:59:46

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

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和普通用户。

2 个答案:

答案 0 :(得分:3)

即使您正在使用sudo用户

,也请尝试#!/usr/bin/env ruby # some external library class ThirdPartyGem module SeeminglyUntouchable extend self def basic_interface( something ) hidden_interface( something ) end private def hidden_interface( bacon ) bacon.capitalize end end def initialize( food ) puts SeeminglyUntouchable.basic_interface( food ) end end # my own code class MyParty < ThirdPartyGem module SeeminglyUntouchable private def hidden_interface( chunky ) chunky.upcase end end end MyParty.new( "i wish this was all upcase" )

答案 1 :(得分:0)

使用最新的npm

npm install -g npm 
相关问题