yodoctor: command not found when installing yo from terminal
Asked Answered
C

2

9

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! [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
Concuss answered 2/11, 2015 at 21:16 Comment(1)
Did you install node/npm will brew or by which method?Dominicadominical
J
5

This error is generally caused because someone used sudo at some point and messed up their npm package directory permissions. As a rule of thumb, never ever use sudo.

So how can you fix it? Here's a couple troubleshooting points:

  1. Make sure you update npm to the latest version (npm install -g npm). npm 2.x had some race conditions that would try to run yodoctor before it is installed.
  2. Make sure the global npm module folders is chown/chmod to your user.
  3. Make sure npm module binaries is in your PATH.
  4. If nothing works, then you can force install it by running npm i -g yeoman-doctor && npm i -g yo - but that really is a last recourse solution.
Jeraldjeraldine answered 3/2, 2016 at 6:42 Comment(0)
H
0

Just the following command would do the trick:

sudo npm install -g yo

if not, find where yo is, add it to the path as follows:

export PATH="$PATH:<path where yo is installed>"
Hamfurd answered 16/3, 2016 at 9:3 Comment(1)
I wanted to reinforce that I think Simon Boudrias' answer is more my situation, and seems like a more appropriate solution. This happened after receiving multiple sudo-required situations, and finally changing my npm prefix: https://mcmap.net/q/46964/-npm-command-sudo-or-not. Similar to what baksosapi said, an npm update, and -h yo install again worked. github.com/yeoman/yo/issues/465#issuecomment-237986250Nanosecond

© 2022 - 2024 — McMap. All rights reserved.