为什么需要全局安装coffeescript?

Why does coffeescript need to be installed globally?

我的 jenkins 构建失败并出现以下错误:

+ npm install

npm WARN prefer global coffee-script@1.12.4 should be installed with -g

想知道为什么需要全局安装 coffee-script 或任何与此相关的包吗?

因为coffeescript是一个命令行工具,可以将coffeescript转译成javascript,或者运行作为一个类似于node的交互式shell。

来自 NPMJS docs:

There are two ways to install npm packages: locally or globally. You choose which kind of installation to use based on how you want to use the package.

If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally. On the other hand, if you want to depend on the package from your own module using something like Node's require, then you want to install locally.

从技术上讲,可以在本地安装这些 CLI 软件包,但是您必须 运行 使用相对路径(例如(未测试)):

./node_modules/coffeescript/bin/coffeescript