![](/img/trans.png)
[英]NPM: should I use one of my dependencies' dependencies, or should I explicitly install it into the project at the root level?
[英]npm install not working after I update my dependencies
我一直在關注Google的角度教程,在執行完step 7
后遇到了麻煩。
我已經這樣更新了bower.json
依賴bower.json
(添加了“ angular-route”:“ bower.json
”):
{
"name": "angular-phonecat",
"description": "A starter project for AngularJS",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-phonecat",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.4.x",
"angular-mocks": "1.4.x",
"jquery": "~2.1.1",
"bootstrap": "~3.1.1",
"angular-route": "~1.4.0"
}
}
這是我輸入的內容:
pavels@pavels:~/Desktop/angular-phonecat$ sudo npm install
這是我的錯誤:
npm WARN cannot run in wd angular-phonecat@0.0.0 bower install (wd=/home/pavels/Desktop/angular-phonecat)
我對諸如AngularJS
類的javascript框架之類的前端東西AngularJS
,該怎么辦才能解決它? 我做錯了什么?
好吧,我已經在全球范圍內安裝了bower(通過運行sudo npm install -g bower
),這是我嘗試從正在工作的目錄中運行bower install
得到的:
/usr/local/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:46
throw err;
^
Error: EACCES, permission denied '/home/pavels/.config/configstore/insight-bower.json'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (fs.js:500:18)
at Object.fs.readFileSync (fs.js:352:15)
at Object.create.all.get (/usr/local/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:27:26)
at Object.Configstore (/usr/local/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:20:44)
at new Insight (/usr/local/lib/node_modules/bower/node_modules/insight/lib/index.js:37:34)
at ensureInsight (/usr/local/lib/node_modules/bower/lib/util/analytics.js:25:19)
at Object.setup (/usr/local/lib/node_modules/bower/lib/util/analytics.js:41:9)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/bin/bower:72:11)
at Module._compile (module.js:460:26)
看來npm無法在工作目錄中運行,請嘗試此操作
sudo npm install --unsafe-perm
如果仍然無法正常工作,請嘗試將以下內容添加到package.json中
"config": {
"unsafe-perm":true
}
第三種選擇是將/ usr / local / lib / node_modules的所有者更改為您的user_name,然后運行不帶sudo的npm insall。
chown -R your_user_name usr/local/lib/node_modules
您有目錄權限問題。 我建議您更改如何安裝node.js。 nvm是解決此問題的好方法。 確保卸載所有全局軟件包(對於每個npm uninstall -g <package>
npm ls -g -depth=0
然后再npm uninstall -g <package>
)。 然后卸載節點並通過nvm重新安裝它。 那應該解決您所有的權限問題。 運行npm install
時,不再需要使用sudo
。
您正在運行sudo npm install
因此安裝腳本 以root身份執行 。 安裝腳本會觸發bower install
,但bower不允許以root用戶身份執行(除非使用--allow-root
選項,但不是這種情況)。
解決方案是放松習慣以root身份啟動npm
。 您可能會遇到EACCESS
錯誤權限,因為npm
文件夾目前由root擁有。 首先遵循修復npm權限 。
然后重試npm install
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.