[英]Cannot run globally installed node modules
I cannot get my Mac OS 10.8.5 to find the modules that npm
installed globally. 我无法让我的Mac OS 10.8.5找到全局安装
npm
的模块。 I am trying to execute bbb
from the command line, but when I try to execute it, I get 我试图从命令行执行
bbb
,但是当我尝试执行它时,我得到了
$ bbb
-bash: bbb: command not found
I believe it is installed correctly: 我相信它安装正确:
$ npm ls -g | grep bbb
├── bbb@1.0.0-wip
├─┬ generator-bbb@0.3.1
├─┬ grunt-bbb-requirejs@0.1.0-alpha.6
├─┬ grunt-bbb-server@0.1.0-alpha.13
├─┬ grunt-bbb-styles@0.1.0-alpha.5
Lots of people recommended putting /usr/local/share/npm/bin
in their $PATH
so I tried that: 很多人建议在他们的
$PATH
放入/usr/local/share/npm/bin
所以我试过了:
$ env | grep PATH
PATH=/usr/local/bin:/usr/local/opt/ruby/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/local/opt/ruby/bin:/usr/local/share/npm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
NODE_PATH=/usr/local/lib/node_modules
Does anyone have any other ideas with what can be going wrong? 有没有人对可能出现的问题有任何其他想法? Thanks.
谢谢。
If you look in bbb 's package.json
, it has no bin
property, so you can't execute the command from the command line because it was not written to have command line functionality. 如果你查看bbb的
package.json
,它没有bin
属性,所以你不能从命令行执行命令,因为它没有写入命令行功能。 Not all Node.js modules are created with use on the command line. 并非所有Node.js模块都是在命令行上使用创建的。
the bin
of the location where your npm is installing the global packages needs to be in your path. 你的npm安装全局包的位置的
bin
需要在你的路径中。
For example when i install a global package i get: 例如,当我安装一个全局包时,我得到:
npm install -g npm-check-updates /usr/local/Cellar/node/0.10.32/bin/ncu -> /usr/local/Cellar/node/0.10.32/lib/node_modules/npm-check-updates/bin/ncu /usr/local/Cellar/node/0.10.32/bin/npm-check-updates -> /usr/local/Cellar/node/0.10.32/lib/node_modules/npm-check-updates/bin/npm-check-updates
You can see in the output above that directory where my executable files are is: /usr/local/Cellar/node/0.10.32/bin
. 您可以在上面的输出中看到我的可执行文件所在的目录:
/usr/local/Cellar/node/0.10.32/bin
。 So in my case I have added that location to my path. 所以在我的情况下,我已将该位置添加到我的路径中。
Check your bin
location and add that. 检查您的
bin
位置并添加它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.