简体   繁体   English

无法使用nvm全局安装Express-Generator

[英]Cannot install express-generator globally with nvm

I'm using NVM to avoid using sudo to install things globally. 我正在使用NVM来避免使用sudo在全局范围内进行安装。 It works fine for everything from Bower, to Grunt, etc. However, when I do npm install -g express-generator it doesnt work. 从Bower到Grunt等,它都能正常工作。但是,当我执行npm install -g express-generator它不起作用。 For example, heres what I get when I globally install Bower: 例如,以下是我在全局安装Bower时得到的信息:

npm install -g bower /Users/jrdillon522/.node/bin/bower -> /Users/jrdillon522/.node/lib/node_modules/bower/bin/bower bower@1.3.12 /Users/jrdillon522/.node/lib/node_modules/bower ├── is-root@1.0.0 ... ... ... ├── update-notifier@0.2.0 (semver-diff@0.1.0, string-length@0.1.2, latest-version@0.2.0, configstore@0.3.1) ├── mout@0.9.1 ├── handlebars@2.0.0 (optimist@0.3.7, uglify-js@2.3.6) ├── inquirer@0.7.1 (figures@1.3.3, mute-stream@0.0.4, through@2.3.6, readline2@0.1.0, lodash@2.4.1, cli-color@0.3.2, rx@2.3.14) └── insight@0.4.3 (object-assign@1.0.0, async@0.9.0, chalk@0.5.1, os-name@1.0.1, lodash.debounce@2.4.1, tough-cookie@0.12.1, configstore@0.3.1, inquirer@0.6.0)

Works fine right? 正常吗? When I install the Express Generator I get the classic error: 安装Express Generator时,出现经典错误:

npm ERR! npm ERR! Please try running this command again as root/Administrator. 请尝试以root / Administrator身份再次运行此命令。

So I run sudo npm install -g express-generator . 所以我运行sudo npm install -g express-generator Heres what I get then: 这就是我得到的:

sudo npm install -g express-generator Password: /Users/myName/.node/bin/express -> /Users/myName/.node/lib/node_modules/express-generator/bin/express express-generator@4.9.0 /Users/myName/.node/lib/node_modules/express-generator ├── mkdirp@0.5.0 (minimist@0.0.8) └── commander@1.3.2 (keypress@0.1.0) ➜ ~ express -v zsh: command not found: express ➜ ~

Why?? 为什么??

It looks like your bin path ( /Users/myName/.node/lib/node_modules/express-generator/bin/express ) isn't added to your environment. 您的bin路径( /Users/myName/.node/lib/node_modules/express-generator/bin/express )似乎未添加到您的环境中。

If you modify your .bashrc file, add the following line to the bottom of your file to make things work as expected: 如果您修改.bashrc文件,请在文件底部添加以下行以使事情按预期进行:

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

Then retry the installation. 然后重试安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM