1

我按照说明安装了咖啡脚本。

$ npm install http://github.com/jashkenas/coffee-script/tarball/master
npm http GET http://github.com/jashkenas/coffee-script/tarball/master   
npm http 200 http://github.com/jashkenas/coffee-script/tarball/master
npm http GET https://registry.npmjs.org/mkdirp
npm http 200 https://registry.npmjs.org/mkdirp
npm WARN package.json cookie-signature@1.0.0 No repository field.
npm WARN package.json fresh@0.1.0 No repository field.
npm WARN package.json methods@0.0.1 No repository field.
npm WARN package.json range-parser@0.0.4 No repository field.
npm WARN package.json send@0.1.0 No repository field.
npm WARN package.json ms@0.1.0 No repository field.
npm WARN package.json pause@0.0.1 No repository field.
npm WARN package.json bytes@0.2.0 No repository field.
npm WARN package.json formidable@1.0.11 No repository field.
npm WARN package.json css@1.0.8 No repository field.
npm WARN package.json uglify-js@2.2.5 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
npm WARN package.json walk@2.2.1 No repository field.   
npm WARN package.json css-parse@1.0.4 No repository field.
npm WARN package.json css-stringify@1.0.5 No repository field.
coffee-script@1.6.3 node_modules/coffee-script
└── mkdirp@0.3.5

然而,当我执行“咖啡”命令时,我得到了

$ coffee
-bash: coffee: command not found

我究竟做错了什么?

PS:我在 Mac 终端上执行此操作

编辑: -

当我安装nodemonnpm install 时会发生同样的问题,类似于上面。但是当我在提示符下输入nodemon命令时,$它说-bash: nodemon: command not found

4

2 回答 2

4

I installed coffeescript on my mac yeasterday as a matter of fact. Here is how I did it:

First of all, go install NodeJS.

Then go in Terminal and type the following: sudo npm install -g coffee-script

That's it - If you type in coffee in Terminal, it should start without a problem

于 2013-08-03T13:58:00.740 回答
2

任何你想作为命令运行的东西(nodemon、coffee、node-inspector)都必须安装npm install -g the-package-name. 如果您使用npm install它,只需将其放入本地 node_modules 目录,并且不会为命令行执行创建符号链接。

如果您发现需要使用sudo,您可能需要阅读这篇博文: http: //howtonode.org/introduction-to-npm

什么,没有sudo?

我强烈建议您不要使用 sudo 进行包管理!包可以运行任意脚本,这使得 sudo 包管理器命令与电锯理发一样安全。当然,它的速度很快,而且肯定会克服任何障碍,但你可能真的希望那个障碍留在那里。

我建议这样做一次:

sudo chown -R $USER /usr/local

于 2013-08-08T01:36:21.053 回答