2017-06-15 55 views
0

我无法安装我的项目(在节点6下工作得很好)。这是由于节点8的依赖关系,即除了被弃用之外,还尝试写入没有权限的地方。无法安装节点8依赖于Ubuntu 16.4

[email protected]:~/share_place/bin$ sudo npm i 
npm WARN deprecated [email protected]: Use uuid module instead 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade 
npm WARN deprecated [email protected]: to-iso-string has been deprecated, use @segment/to-iso-string instead. 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to [email protected]^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree. 
npm ERR! code 1 
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b v0.5.5 git://github.com/bookchin/node-ntp-client.git /home/ubuntu/.npm/_cacache/tmp/git-clone-cd074428 
npm ERR! /home/ubuntu/.npm/_cacache/tmp/git-clone-cd074428/.git: Permission denied 
npm ERR! 

npm ERR! A complete log of this run can be found in: 
npm ERR!  /home/ubuntu/.npm/_logs/2017-06-15T13_45_37_010Z-debug.log 
[email protected]:~/share_place/bin$ node -v 
v8.1.2 

这对我们来说非常令人沮丧,因为我们在Windows和Mac下的发展没有问题,但现在我们停留在试生产。

任何帮助将是非常欢迎,感谢

回答

4

如果npm正在运行的(因为sudo)的根,它会正确执行外部脚本/程序(如git)之前放弃root特权。 By default它会设置为nobody

这会导致权限问题,因为nobody是最有可能不允许写入该目录/home/ubuntu/.npm/_cacache/tmp/git-clone-cd074428/(因此“权限被拒绝”错误)。

最好的解决方案是根本不使用sudo。在你的情况下,只安装本地依赖关系,它比通常的情况更没有意义,其中sudo用于全局安装(-g)。

也许你可能要清理权限/home/ubuntu/.npm/也一样,如果某些文件/在那里目录现在属于root

​​