3

According to the Gulp.js documentation, in order to be able to use Gulp you have to install it globally:

npm install --global gulp

and locally:

npm install --save-dev gulp

And the local installation is essential, because without doing npm install gulp or npm link gulp in your project's directory Gulp just throws a completely random exception: TypeError: Invalid Version: undefined.

I'm wondering - why Gulp requires local installation? What is the point in keeping copies of Gulp inside every project's folder (apart from wasting hard drive space)? And is there any way to install and use Gulp only globally?

ovk
  • 2,318
  • 1
  • 23
  • 30

1 Answers1

1

Well, I think that way, if another developer clones your project and runs npm install, it'll install gulp for them automatically, because there's nothing in the package.json saying they must have gulp. I guess if they were to see a gulpfile.js, it would be kind of obvious, but it's always good to err on the side of helping future developers.

Also, check out this answer:

When installing a tool globally it's to be used by a user as a command line utility anywhere, including outside of node projects. Global installs for a node project are bad because they make deployment more difficult.

When used in a script field of your package.json, npm searches node_modules for the tool as well as globally installed modules, so the local install is sufficient.

Community
  • 1
  • 1
Josh Beam
  • 19,292
  • 3
  • 45
  • 68