npm不能正确安装全局模块。

3

我的全局模块安装出现了问题。

我的系统

  • 操作系统: OS X Mountain Lion
  • node.js: 0.10.18 (包安装程序)

复现步骤

输入

npm install coffee -g (或者其他任何模块)

输出

npm http GET https://registry.npmjs.org/coffee
npm http 200 https://registry.npmjs.org/coffee
{lots of dependencies}
coffee@0.0.1 /usr/local/lib/node_modules/coffee
├── node-getopt@0.2.3
├── modular-amd@0.1.2
├── chai@1.7.2 (assertion-error@1.0.0)
├── mocha@1.11.0 (growl@1.7.0, debug@0.7.2, commander@0.6.1, diff@1.0.2, mkdirp@0.3.5, ms@0.3.0, jade@0.26.3, glob@3.2.1)
├── express@3.2.6 (methods@0.0.1, fresh@0.1.0, range-parser@0.0.4, cookie-signature@1.0.1, buffer-crc32@0.2.1, cookie@0.1.0, debug@0.7.2, commander@0.6.1, mkdirp@0.3.4, send@0.1.0, connect@2.7.11)
├── sinon@1.7.3 (buster-format@0.5.6)
└── sinon-chai@2.4.0

输入

coffee

输出

-bash: coffee: command not found

其他信息

  • npm config get prefix: /usr/local
  • /usr/local的读/写访问权限: 是
  • $PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
  • /usr/local/share/npm是否存在: 否
  • /usr/local/lib/node_modules/coffee是否存在: 是
  • /usr/local/bin/coffee是否存在: 否

还能做什么?

不会将coffee的直接链接添加到我的$PATH变量中,因为那不是我的工作,那是npm的工作!真的,为什么我要使用npm,而不是自己做呢?我已经读了那个答案100遍,对此我没有任何言语,这些言语都违反了SO的规定。


我使用了来自nodejs.org的包。 - Fabio Poloni
是的,我知道。我已经检查了权限是否有误,但是根用户和我的用户都具有读写访问权限。 - Fabio Poloni
我刚刚发现这个问题只出现在使用Coffee和Grunt时。我尝试安装Less,符号链接添加正确。 - Fabio Poloni
好吧,如果我太蠢了,搞不清楚咖啡、coffee-script、grunt 和 grunt-cli,那一切都完了。我要去找新工作了。谢谢。 - Fabio Poloni
1
哇,用户和耐心相比,0-1,放松一下... - Gntem
显示剩余3条评论
1个回答

2
如果您想全局安装CoffeeScript(如标签之一建议的那样),则应安装coffee-script(而不是coffee)。 此外,在Mac上安装全局模块需要sudo权限。
命令:

sudo npm install coffee-script -g

输入
% coffee

输出

coffee>

我等了三个星期,希望有人能够看到评论并回答。谢谢! - Fabio Poloni
这对我不起作用。我尝试以各种方式(包括使用sudo)安装grunt,并被告知它已经安装在~/local/lib/node_modules/grunt,但bin中没有任何内容,结果我得到了“command-not-found”的错误提示。 - erewok
如果你想要安装Grunt可执行文件,请记得安装 grunt-cli(https://www.npmjs.org/package/grunt-cli),而不是 grunt - Andrei Karpushonak

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接