2015-11-02 107 views
8

以下是我不斷收到的錯誤。它似乎表明與yodoctor「安裝後」的問題。不幸的是,yodoctor是由自我管理團隊提供的建議來幫助解決這個問題。我安裝了其他node_modules(bower,grunt,typescript)。yodoctor:從終端安裝喲時未找到命令

sh: yodoctor: command not found 
npm ERR! Darwin 15.0.0 
npm ERR! argv "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/bin/npm" "install" "-g" "yo" 
npm ERR! node v5.0.0 
npm ERR! npm v3.3.9 
npm ERR! file sh 
npm ERR! code ELIFECYCLE 
npm ERR! errno ENOENT 
npm ERR! syscall spawn 

npm ERR! [email protected] postinstall: `yodoctor` 
npm ERR! spawn ENOENT 
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'yodoctor'. 
npm ERR! This is most likely a problem with the yo package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  yodoctor 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls yo 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  /Users/jesselawson/.node_modules_global/lib/node_modules/npm-debug.log 
+0

你安裝節點/ NPM會釀造或通過哪種方法? – alphapilgrim

回答

3

這個錯誤通常是由於所致有人用sudo在某些時候和搞砸了他們的NPM包目錄的權限。根據經驗,永遠不要使用sudo。

那麼你如何解決它?這裏有幾個故障排除要點:

  1. 確保您將npm更新到最新版本(npm install -g npm)。 npm 2.x有一些競爭條件會在安裝之前嘗試運行yodoctor
  2. 確保全局npm模塊文件夾是chown/chmod to your user
  3. 確保npm module binaries is in your PATH
  4. 如果什麼都行不通,那麼您可以通過運行npm i -g yeoman-doctor && npm i -g yo來強制安裝它 - 但這確實是最後的追索解決方案。
0

只是下面的命令會做的伎倆:

sudo npm install -g yo 

如果沒有,找到在哪裏yo是,把它添加到路徑,如下所示:

export PATH="$PATH:<path where yo is installed>" 
+0

我想強化一下,我認爲西蒙佈德里亞斯的回答更像是我的情況,似乎是一個更合適的解決方案。發生這種情況後收到多個sudo所需的情況,並最終更改我的npm前綴:https://stackoverflow.com/a/25447784/1091943。與baksosapi所說的類似,npm更新和-h yo安裝再次起作用。 https://github.com/yeoman/yo/issues/465#issuecomment-237986250 – Pysis