我正在使用 NVM 来避免使用sudo
全局安装东西。它适用于从 Bower 到 Grunt 等的所有内容。但是,当我这样做时,npm install -g express-generator
它不起作用。例如,这是我在全局安装 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)
工作正常吗?当我安装 Express Generator 时,我得到了经典错误:
npm 错误!请尝试以 root/管理员身份再次运行此命令。
所以我跑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
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
➜ ~
为什么??