2017-06-15 69 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

​​