8

Below is the error I keep getting. It seems to indicate a "post-install" issue with yodoctor. Sadly yodoctor is the advice given by the yeoman team to help with this issue. I have other node_modules installed (bower, grunt, typescript).

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! yo@1.5.0 postinstall: `yodoctor`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the yo@1.5.0 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
4

2 回答 2

4

这个错误通常是因为有人sudo在某个时候使用并弄乱了他们的 npm 包目录权限。根据经验,永远不要使用 sudo。

那么你怎么能解决它呢?这里有几个故障排除点:

  1. 确保将 npm 更新到最新版本 ( npm install -g npm)。yodoctornpm 2.x 有一些竞争条件会在安装之前尝试运行。
  2. 确保全局 npm 模块文件夹是chown/chmod对您的用户
  3. 确保npm 模块二进制文件在您的 PATH中。
  4. 如果没有任何效果,那么您可以通过运行强制安装它npm i -g yeoman-doctor && npm i -g yo- 但这确实是最后的解决方案。
于 2016-02-03T06:42:35.683 回答
0

只需以下命令即可解决问题:

sudo npm install -g yo

如果没有,找到在哪里yo,添加到路径中,如下:

export PATH="$PATH:<path where yo is installed>"
于 2016-03-16T09:03:47.693 回答