找不到“ yo”二进制文件。确保已安装它并在$ PATH中。你能告诉我问题是什么吗?

时间:2019-09-27 10:30:00

标签: yeoman yeoman-generator

I'm using npm install -g yo gulp to install yeoman and this is the error I'm getting  
npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
C:\Usr\local\gulp -> C:\Usr\local\node_modules\gulp\bin\gulp.js
C:\Usr\local\yo -> C:\Usr\local\node_modules\yo\lib\cli.js
C:\Usr\local\yo-complete -> C:\Usr\local\node_modules\yo\lib\completion\index.js

> yo@3.1.0 postinstall C:\Usr\local\node_modules\yo
> yodoctor


Yeoman Doctor
Running sanity checks on your system

√ No .bowerrc file in home directory
√ Global configuration file is valid
√ NODE_PATH matches the npm root
√ No .yo-rc.json file in home directory
√ Node.js version
{ Error: Couldn't find the 'yo' binary. Make sure it's installed and in your $PATH
    at notFoundError (C:\Usr\local\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.js:8:11)
    at verifyENOENT (C:\Usr\local\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.js:43:16)
    at ChildProcess.cp.emit (C:\Usr\local\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.js:30:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn yo',
  cmd: 'C:\\WINDOWS\\system32\\cmd.exe /s /c "yo "--version""' }
× yo version
{ Error: Couldn't find the 'yo' binary. Make sure it's installed and in your $PATH
    at notFoundError (C:\Usr\local\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.js:8:11)
    at verifyENOENT (C:\Usr\local\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.js:43:16)
    at ChildProcess.cp.emit (C:\Usr\local\node_modules\yo\node_modules\cross-spawn-async\lib\enoent.js:30:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn yo',
  cmd: 'C:\\WINDOWS\\system32\\cmd.exe /s /c "yo "--version""' }
√ npm version

Found potential issues on your machine :(
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\gulp\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ gulp@4.0.2
+ yo@3.1.0
updated 2 packages in 23.31s

5 个答案:

答案 0 :(得分:3)

运行以下命令以查看npm将全局软件包放在何处

npm config get prefix

您将获得与此类似的输出

/usr/local/Cellar/node/10.5.0_1

复制输出或路径,然后使用任何代码编辑器打开您的.bashrc或.zshrc文件,具体取决于您所使用的终端,并像这样粘贴

export PATH="$PATH:"/usr/local/Cellar/node/10.5.0_1/bin/""

然后保存运行

source ~/.zshrc

答案 1 :(得分:0)

我遇到了同样的问题,我真的不想卸载Node.js,因为我安装了很多软件包。 也尝试了第二个答案,但没有用。

然后我发现它已打勾,即已关闭:

https://github.com/yeoman/yeoman/issues/1716

使用yarn命令安装对我有用。

yarn global add yo

然后安装完成并安装了二进制文件。

Nevermind尝试使用npm来安装它,并得到同样的错误,因此希望提供更多信息

答案 2 :(得分:0)

我刚刚在MacOS上遇到了这个问题,发现我的所有全局npm二进制文件都符号链接到/usr/local/bin目录中,除了yo之外。我使用以下命令创建了符号链接:

ln -s /usr/local/Cellar/node/12.10.0/bin/yo /usr/local/bin/yo

(您的情况可能有所不同)

yo现在可以调用了。

答案 3 :(得分:0)

以上对我来说根本不起作用。

以下解决了我的问题: 清理已安装的nodejs,然后在线程https://github.com/zkat/npx/issues/100中执行dv-步骤 请注意,我的npm一直指向C:\ usr ...

我认为我将npm config set prefix=设置为错误,这是由于我正在获取错误。这是我的解决方法:

以“管理员”模式打开CMD。

npm cache clear --force

npm install

npm config set cache C:\Users\myname\AppData\Roaming\npm-cache

npm config set prefix C:\Users\myname\AppData\Roaming\npm

答案 4 :(得分:0)

像Xander Cage一样。

  1. 我已卸载node.js-> procedure here
  2. 我已经重新启动计算机。
  3. 然后我再次安装了node.js

可以。

豫ICP备18024241号-1