MacOS Catalina安装Yeoman失败:找不到'yo'二进制文件求助
Hey there, let’s work through this Yeoman issue you’re hitting on macOS Catalina! I see you’ve already tried clearing the npm cache, reinstalling yo, and even adding yeoman-doctor, but you’re still getting that frustrating "Couldn't find the 'yo' binary" error from yodoctor. This problem almost always boils down to npm's global bin directory not being in your system PATH or incorrect file permissions. Here’s how to fix it:
Step 1: Locate npm’s Global Bin Directory
First, find where npm stores global binaries by running:
npm config get prefix
From your install logs, this should return /Users/William/.npm-global—so the actual bin folder (where yo lives) is /Users/William/.npm-global/bin.
Step 2: Add the Bin Directory to Your System PATH
Next, check if this directory is already in your PATH:
echo $PATH
If /Users/William/.npm-global/bin isn’t listed, you need to add it permanently:
For Zsh (Catalina’s default shell):
- Open your zsh config file:
open ~/.zshrc
- Paste this line at the end of the file:
export PATH="/Users/William/.npm-global/bin:$PATH"
- Save the file and apply the changes immediately:
source ~/.zshrc
For Bash (if you use it instead):
- Open your bash profile:
open ~/.bash_profile
- Add the same PATH line, then apply changes:
source ~/.bash_profile
Step 3: Verify yo Works
Now test if yo is accessible by running:
yo --version
If this outputs a version number, the path issue is fixed. Run yodoctor again, and the "missing binary" error should be gone.
Step 4: Fix Permission Issues (If Needed)
If the above steps don’t work, it might be because using sudo to install yo gave the file root-only permissions. Fix this by:
- Taking ownership of npm’s global directory:
sudo chown -R $USER:$GROUP ~/.npm-global
- Reinstall
yoand the generator without sudo:
npm install -g yo generator-code
Quick Note on Deprecation Warnings
The deprecated dependency warnings you’re seeing (like urix@0.1.0 or request@2.88.2) are normal—they’re from older packages that Yeoman still uses, but they don’t break core functionality. You can safely ignore them for now.
内容的提问来源于stack exchange,提问作者uncannyorange

