0

yo一开始,我已经generator-angular安装了/usr/local/lib/node_modules(通过做坏事sudo npm install -g ...)。

然后我阅读了 isaccs 关于如何在没有 sudo 的情况下使 npm 和 yo 工作的建议,并修改了他的步骤以使所有行都正常工作。所以我也得到yogenerator-angular安装了~/.node/lib/node_modules

最后,怀疑yo可能是从原始目录运行的,我删除了/usr/local/lib/node_modules. 我在“~/”中创建了一个全新的目录并调用yo angular了它,但是遇到了:yo: command not found.

是否有命令告诉我从哪个目录yo运行?

我怎么知道yo它应该从哪里运行~/.node/lib/node_modules


更多信息:

我的$PATH/home/ubuntu/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

我的~/.bashrc包含export PATH=$HOME/local/bin:$PATH
我的~/.npmrc包含prefix = /home/ubuntu/.node

$ ls -l ~/.node/lib/node_modules/
total 24
drwxr-xr-x  7 nobody ubuntu 4096 Feb 17 21:57 bower
drwxr-xr-x 19 nobody ubuntu 4096 Feb 22 01:19 generator-angular
drwxr-xr-x  4 nobody ubuntu 4096 Feb 17 22:00 generator-karma
drwxr-xr-x  6 nobody ubuntu 4096 Feb 17 21:57 grunt-cli
drwxr-xr-x 10 nobody ubuntu 4096 Feb 17 23:15 npm
drwxr-xr-x  4 nobody ubuntu 4096 Feb 17 22:00 yo
4

1 回答 1

0

1.Install nvm:

$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh

2.Use nvm to install node and npm. Reopen your terminal and run the following commands in turn:

$ nvm install 0.10.26

$ npm install -g yo

$ npm install -g generator-angular

yo and generator-angular will be installed in ~/.nvm/v0.10.26/lib/node_modules. You can run them directly in the terminal now:

$ yo -v

3.Run which yo to find the directory yo is running from.

于 2014-02-22T03:43:24.183 回答