2015-10-06 252 views
-2

npm install express會導致以下錯誤。如何解決此問題?這個問題已經有很多重複的錯誤答案,我與下面的正確答案分享了這個問題,以澄清事情。安裝npm install express-generator時出錯-g

-bash-3.2$ npm install express-generator -g 
npm WARN engine [email protected]: wanted: {"node":">= 0.10"} (current: {"node":"v0.9.4-pre","npm":"1.4.16"}) 
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/bin/express' 
npm ERR! error rolling back [email protected] { [Error: EACCES, unlink '/usr/local/bin/express'] errno: 3, code: 'EACCES', path: '/usr/local/bin/express' } 
npm ERR! Error: EACCES, unlink '/usr/local/bin/express' 
npm ERR! { [Error: EACCES, unlink '/usr/local/bin/express'] errno: 3, code: 'EACCES', path: '/usr/local/bin/express' } 
npm ERR! 
npm ERR! Please try running this command again as root/Administrator. 

npm ERR! System Linux 2.6.23.17-88.fc7 
npm ERR! command "node" "/usr/local/bin/npm" "install" "express-generator" "-g" 
npm ERR! cwd /home/sukumar/www/nodejs/socialgrow 
npm ERR! node -v v0.9.4-pre 
npm ERR! npm -v 1.4.16 
npm ERR! path /usr/local/bin/express 
npm ERR! code EACCES 
npm ERR! errno 3 
npm ERR! stack Error: EACCES, unlink '/usr/local/bin/express' 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /home/sukumar/www/nodejs/socialgrow/npm-debug.log 
npm ERR! not ok code 0 

回答

-1

您只能以root/admin身份在全局安裝模塊(-g)。以root身份運行並重試。

+0

這個答案有什麼問題?請不要在沒有評論的情況下投票。 – Manu

+0

在回答 –

+0

@Manu作爲初學者之前,您應該檢查其是否重複,這是不正確的。例如,如果你用'nvm'安裝'node',你不需要(甚至不推薦*)安裝root訪問。這一切都取決於你的節點和npm的安裝位置。另外,在關於該問題的評論中找到的重複部分中提到了它。 –