npm - 优医生 : command not found when installing yo from terminal

标签 npm yeoman yeoman-generator yo

下面是我不断收到的错误。这似乎表明 yodoctor 存在“安装后”问题。遗憾的是 yodoctor 是 yeoman 团队提供的建议来帮助解决这个问题。我安装了其他node_modules(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

最佳答案

此错误通常是因为有人在某些时候使用了 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来强制安装它 - 但这确实是最后的解决方案。

关于npm - 优医生 : command not found when installing yo from terminal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33487085/

相关文章:

node.js - NPM:npm 安装在 fetchMetaData -> addTmpTa 上挂起

node.js - Dokku找不到 'webpack'

azure - Azure 网站上的 Yeoman 生成器 gulp-Angular 部署

node.js - WebStorm 7 - Yeoman Angular 缺少源映射 `Failed to load resource: the server responded with a status of 404 (Not Found)`

javascript - 使用 Yeoman 生成器复制文件不起作用

javascript - Node.js 找不到已安装的模块

mocha.js - 使用 bowerInstall 和/或 npmInstall 测试 Yeoman 生成器

javascript - 运行 grunt "error occurred while processing a template"时出错

node.js - laravel5 的 yeoman 生成器 - composer create-project 的问题

node.js - npm并发错误?同时运行前端和后端时?