如何修复"yo:未找到命令"安装Yeoman之后 [英] How to fix "yo: command not found" after installing Yeoman

查看:921
本文介绍了如何修复"yo:未找到命令"安装Yeoman之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照以下说明,我尝试使用npm两次安装yeoman: http://yeoman.io/learning/index.html

Following these instructions, I tried to install yeoman using npm twice: http://yeoman.io/learning/index.html

第一次失败后,我按照以下说明卸载了节点: 我如何完全卸载Node.js,然后从头开始安装(Mac OS X)然后,我通过一个错误安装了nvm和node/npm(通过nvm):

After the first failure, I uninstalled node using these instructions: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) Then, I installed nvm and node/npm (via nvm) with one error:

[Yeoman Doctor] Uh oh, I found potential errors on your machine
---------------

[Error] NPM root value is not in your NODE_PATH
  [info]
    NODE_PATH = /Users/joanna/.nvm/v0.10.22/lib/node_modules:.
    NPM root  = /Users/joanna/.node/lib/node_modules

  [Fix] Append the NPM root value to your NODE_PATH variable
    Add this line to your .bashrc
      export NODE_PATH=$NODE_PATH:/Users/joanna/.node/lib/node_modules
    Or run this command
      echo "export NODE_PATH=$NODE_PATH:/Users/joanna/.node/lib/node_modules" >> ~/.bashrc && source ~/.bashrc

我粘贴了该命令,然后再次运行npm install -g yo.

I pasted that command in, and then I ran npm install -g yo again.

再次按照yeoman网站上的说明进行操作后,仍然找不到yeoman.我收到此错误: -bash:哟:找不到命令

After following the instructions from the yeoman site again, it still can't find yeoman. I receive this error: -bash: yo: command not found

怎么了?约曼博士说:一切都很好!"

What is wrong? The Yeoman Doctor says: "Everything looks alright!"

推荐答案

问题的根源是您同时使用NVM时设置了NODE_PATH.使用NVM时,根本不应该使用NODE_PATH变量,因为NVM会在其特定于版本的根目录中安装全局软件包.

The source of the problem is that you have NODE_PATH set while using NVM at the same time. When you use NVM you shouldn't have a NODE_PATH variable at all, since NVM installs global packages in its version specific root.

删除NODE_PATH中的所有软件包,删除环境变量,然后安装yo和生成器或所需的任何其他全局软件包.您将看到它停止抱怨,并且所有操作最终都在与当前版本匹配的nvm子目录中.

Delete all packages that are in your NODE_PATH, remove the environment variable, and install yo and the generators or any other global packages you need. You will see that it stops complaining and everything ends up in the nvm subdirectory matching the current version.

在NVM中开始使用其他Node版本时,请重新安装全局软件包.这将使所有内容按照其预期的版本进行整齐地组织.

When you start using a different Node version in NVM, reinstall the global packages. This will keep everything organised neatly by version like its meant to be.

此处有关此讨论的更多信息: https://github.com/creationix/nvm/pull/97

More info on this discussion here: https://github.com/creationix/nvm/pull/97

这篇关于如何修复"yo:未找到命令"安装Yeoman之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆