我通過Elastic Beanstalk配置了一個默認的乾淨node.js應用程序,並且有一個node.js腳本嘗試在項目目錄中運行npm install
(/var/app/current/deploy-dist
),但是,下面的權限錯誤被拋出:錯誤:在Elastic Beanstalk上運行`npm install`時EACCES:權限被拒絕
npm WARN locking Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm WARN locking at Error (native)
npm WARN locking /tmp/.npm/_locks/staging-f212e8d64a01707f.lock failed { Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm WARN locking at Error (native)
npm WARN locking errno: -13,
npm WARN locking code: 'EACCES',
npm WARN locking syscall: 'open',
npm WARN locking path: '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock' }
npm WARN deploy-dist No description
npm WARN deploy-dist No repository field.
npm WARN deploy-dist No license field.
npm ERR! Linux 4.4.35-33.55.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/npm" "install"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! path /tmp/.npm/_locks/staging-f212e8d64a01707f.lock
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/deploy-dist/npm-debug.log
的package.json
只是一個:
{
"dependencies": {
"node-fetch": "^1.3.3"
}
}
運行npm install
使用sudo明顯的作品,但最好避免,因爲 一個辦法。
將NPM_CONFIG_PREFIX
設置爲目錄~
根據npm
docs suggestion也沒有工作,問題仍然存在。
我懷疑問題出在/tmp/.npm
不正確的權限,這是
drwxr-xr-x 114 root root 4.0K Dec 27 17:04 .npm
這是混亂的,如我所料簡單npm install
工作開箱。
UPDATE:不該該項目目錄已包含node_modules
文件夾,但即使取出並運行npm install
不能解決問題。
有人似乎具有完全相同的問題在AWS論壇以及現在:https://forums.aws.amazon.com/thread.jspa?messageID=758699&tstart=0 – Sbbs
你是如何在這個Elastic Beanstalk實例中用sudo運行「npm install」的?這不是這樣,但我可以用這個臨時解決方法來測試我的應用程序。 – sergi
@sergi'sudo /opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/node /opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/npm install ' – Sbbs