为什么需要在全球范围内安装coffeescript?

时间:2017-04-09 00:35:25

标签: npm coffeescript npm-install

我有一个jenkins构建失败,出现以下错误:

  

+ npm install

     

npm WARN首选全局coffee-script@1.12.4应与-g

一起安装

好奇为什么需要在全球范围内安装咖啡脚本或任何包装?

1 个答案:

答案 0 :(得分:1)

Because coffeescript is a command line tool which can transpile coffeescript into javascript, or run as as an interactive shell similar to node.

from the 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.

It would technically be possible to install these CLI packages locally, but then you would have to run them using a relative path such as(untested):

./node_modules/coffeescript/bin/coffeescript