2014-11-05 34 views
1

我正在使用NVM来避免使用sudo来全局安装东西。它适用于从鲍尔到Grunt等等的一切。但是,当我做npm install -g express-generator它不起作用。例如,继承人我所得到的,当我在全球安装鲍尔:不能使用nvm在全局安装快速生成器

npm install -g bower /Users/jrdillon522/.node/bin/bower -> /Users/jrdillon522/.node/lib/node_modules/bower/bin/bower [email protected] /Users/jrdillon522/.node/lib/node_modules/bower ├── [email protected] ... ... ... ├── [email protected] ([email protected], [email protected], [email protected], [email protected]) ├── [email protected] ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) └── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

工作正常吗?当我安装Express Generator时,我得到了经典错误:

npm ERR! Please try running this command again as root/Administrator.

所以我运行了sudo npm install -g express-generator。继承人我得到什么,那么:

sudo npm install -g express-generator Password: /Users/myName/.node/bin/express -> /Users/myName/.node/lib/node_modules/express-generator/bin/express [email protected] /Users/myName/.node/lib/node_modules/express-generator ├── [email protected] ([email protected]) └── [email protected] ([email protected]) ➜ ~ express -v zsh: command not found: express ➜ ~

为什么?

回答

1

看起来您的bin路径(/Users/myName/.node/lib/node_modules/express-generator/bin/express)未添加到您的环境中。

如果修改.bashrc文件,以下行添加到文件底部,以使事情按预期工作:

export PATH=$PATH:/Users/myName/.node/lib/node_modules/express-generator/bin 

然后重试安装。

+1

所以我实际上不得不将它添加到我的'.zshrc'文件中,但是,工作。我不得不这样做很奇怪,这可能意味着什么是错的。但那确实解决了它。谢谢! – JDillon522 2014-11-07 17:50:19

+0

乐意帮忙! <33 – rdegges 2014-11-07 17:50:54