【问题标题】:yo: command not foundyo: 找不到命令
【发布时间】:2014-07-24 10:30:54
【问题描述】:

我已经安装了 chris lea 版本的 nodejs:

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

比使用 npm 安装 yeoman、grund-cli 和 bower:

sudo npm install -g yo grunt-cli bower

一切都很好,包括“[Yeoman Doctor] 一切看起来都很好!”在 yeoman 安装结束时。

/home/gabriela/npm/bin/yo -> /home/gabriela/npm/lib/node_modules/yo/cli.js
> yo@1.1.2 postinstall /home/gabriela/npm/lib/node_modules/yo
> node ./scripts/doctor

比我跑:

gabriela@Gabriela-Ubuntu:~$ which node
/usr/bin/node
gabriela@Gabriela-Ubuntu:~$ which npm
/usr/bin/npm
gabriela@Gabriela-Ubuntu:~$ which bower
/usr/bin/bower
gabriela@Gabriela-Ubuntu:~$ which yo
gabriela@Gabriela-Ubuntu:~$ yo
yo: command not found
gabriela@Gabriela-Ubuntu:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME:$JRE_HOME

出了什么问题?我是否必须执行任何其他命令才能正确安装 yeoman?

【问题讨论】:

  • 你运行的是哪个节点版本
  • “node -v”给了我“v0.10.28”
  • npm --version 怎么样
  • 这是你的问题-我相信-看看我的答案
  • 根据这个链接Node v0.10.28 (Stable),node v0.10.28 在 1.4.9 与 npm 一起工作。

标签: ubuntu npm yeoman


【解决方案1】:

根据文档getting started yo 将安装bowergrunt。 你需要做的是删除gruntyo然后重新安装yo

npm uninstall -g grunt yo

npm install -g yo

npm install -g yo

如果您使用的是 npm 1.2.10 或更高版本,这也会自动 为您安装 grunt 和 bower。如果您使用的是旧版本的 npm, 您需要手动安装它们

如果您过去在全局范围内安装了 Grunt,则需要 先删除它:npm uninstall -g grunt

【讨论】:

  • 我有一个'未安装在 /home/gabriela/npm/lib/node_modules: "grunt"' 和 '未安装在 /home/gabriela/npm/lib/node_modules: "yo"'但是凉亭被卸载了:'unbuild bower@1.3.4'。
  • @GabrielaVasselai - 检查此question 以了解如何卸载
  • 对不起,我在卸载 grunt-cli 和 yo 时忘记了 -g。现在我得到了一个 'unbuild yo@1.1.2' 和一个 'unbuild grunt-cli@0.1.13' 但是 grunt-cli 我必须用 sudo 卸载。第一次尝试给了我一个“请尝试以 root/管理员身份再次运行此命令”。
【解决方案2】:

我真的不知道它为什么会丢失。因此,经过一系列测试后,我解决了创建符号链接的问题。

gabriela@Gabriela-Ubuntu:/$ sudo ln -s /home/gabriela/npm/bin/yo /usr/bin/yo
gabriela@Gabriela-Ubuntu:/$ yo
[?] What would you like to do? (Use arrow keys)
‣ Run the Angular-bootstrap generator (0.4.1) 
  Update your generators 
  Install a generator 
  Find some help 
  Get me out of here!

【讨论】:

  • 这真的有效!您应该将自己的答案标记为已接受,这完全可以,并且可能会向未来的用户暗示这是一个可靠的解决方案。
猜你喜欢
  • 2015-07-20
  • 2016-02-02
  • 1970-01-01
  • 1970-01-01
  • 2015-09-05
  • 1970-01-01
  • 2014-10-09
  • 1970-01-01
  • 2021-02-10
相关资源
最近更新 更多