2014-04-11 151 views
126

出於某種原因與npm install -g express我的機器上全局安裝快車後,如果我cd到一個目錄,並嘗試運行表現,我得到以下錯誤:快遞找不到命令

express: command not found. 

即使我sudo運行我仍然得到相同的輸出。我已經嘗試了多種不同的解決方案來解決這個問題,並沒有任何工作。我已經通過homebrew安裝了節點,Stack Overflow上的一些線程可能是一個問題,所以我完全卸載節點並通過nodejs.org上的安裝程序重新安裝(我現在正在運行v0.10.26),問題仍然存在。

如果我進入我的/usr/local/lib/node_modules Express在那裏,但在/ usr/local/bin中,Express沒有任何內容。我不確定這是否有問題,但考慮到該目錄中有其他全局安裝的節點軟件包的二進制文件,我認爲可能存在某些問題。

這是當我安裝了精確的輸出我得到:

npm http GET https://registry.npmjs.org/express 
npm http 304 https://registry.npmjs.org/express 
npm http GET https://registry.npmjs.org/accepts/1.0.0 
npm http GET https://registry.npmjs.org/type-is/1.0.0 
npm http GET https://registry.npmjs.org/range-parser/1.0.0 
npm http GET https://registry.npmjs.org/cookie/0.1.0 
npm http GET https://registry.npmjs.org/fresh/0.2.2 
npm http GET https://registry.npmjs.org/buffer-crc32/0.2.1 
npm http GET https://registry.npmjs.org/send/0.2.0 
npm http GET https://registry.npmjs.org/methods/0.1.0 
npm http GET https://registry.npmjs.org/cookie-signature/1.0.3 
npm http GET https://registry.npmjs.org/utils-merge/1.0.0 
npm http GET https://registry.npmjs.org/merge-descriptors/0.0.2 
npm http GET https://registry.npmjs.org/escape-html/1.0.1 
npm http GET https://registry.npmjs.org/serve-static/1.0.1 
npm http GET https://registry.npmjs.org/qs/0.6.6 
npm http GET https://registry.npmjs.org/path-to-regexp/0.1.2 
npm http GET https://registry.npmjs.org/parseurl/1.0.1 
npm http GET https://registry.npmjs.org/debug 
npm http 304 https://registry.npmjs.org/cookie/0.1.0 
npm http 304 https://registry.npmjs.org/type-is/1.0.0 
npm http 304 https://registry.npmjs.org/buffer-crc32/0.2.1 
npm http 304 https://registry.npmjs.org/methods/0.1.0 
npm http 304 https://registry.npmjs.org/accepts/1.0.0 
npm http 304 https://registry.npmjs.org/range-parser/1.0.0 
npm http 304 https://registry.npmjs.org/cookie-signature/1.0.3 
npm http 304 https://registry.npmjs.org/fresh/0.2.2 
npm http 304 https://registry.npmjs.org/serve-static/1.0.1 
npm http 304 https://registry.npmjs.org/qs/0.6.6 
npm http 304 https://registry.npmjs.org/utils-merge/1.0.0 
npm http 304 https://registry.npmjs.org/merge-descriptors/0.0.2 
npm http 304 https://registry.npmjs.org/escape-html/1.0.1 
npm http 304 https://registry.npmjs.org/path-to-regexp/0.1.2 
npm http 304 https://registry.npmjs.org/parseurl/1.0.1 
npm http 304 https://registry.npmjs.org/debug 
npm http 304 https://registry.npmjs.org/send/0.2.0 
npm http GET https://registry.npmjs.org/mime 
npm http GET https://registry.npmjs.org/send/0.1.4 
npm http GET https://registry.npmjs.org/mime 
npm http GET https://registry.npmjs.org/negotiator 
npm http 304 https://registry.npmjs.org/mime 
npm http 304 https://registry.npmjs.org/mime 
npm http 304 https://registry.npmjs.org/send/0.1.4 
npm http GET https://registry.npmjs.org/range-parser/0.0.4 
npm http GET https://registry.npmjs.org/fresh/0.2.0 
npm http 304 https://registry.npmjs.org/negotiator 
npm http 304 https://registry.npmjs.org/range-parser/0.0.4 
npm http 304 https://registry.npmjs.org/fresh/0.2.0 
[email protected] /usr/local/lib/node_modules/express 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected]) 
└── [email protected] ([email protected], [email protected]) 

回答

333

隨着快速的發佈4.0.0,它看起來像你需要做的sudo npm install -g express-generator

+2

這工作非常感謝您的幫助!我準備在昨晚拉我的頭髮。 –

+0

它也適用於我。謝謝! –

+0

你是救命的人:)謝謝! – nia

31

你需要運行:

npm install -gd express-generator 

原來的快遞與CLI,現在CLI拆分成獨立的快遞發電機包。本來由項目生成的是運行express節點app.js,因爲httpserver在app.js中的相關代碼,現在這部分代碼到工程目錄bin/www下面,app.js只保留實現app邏輯代碼,需要運行bin/www。只是一個非常簡單的應用程序和優化包依賴版本更改。