Why does Gulp.js require local installation in addition to global installation?

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

npm install --global gulp

      

and locally:

npm install --save-dev gulp

      

And local installation is very important, because without execution npm install gulp

or npm link gulp

in project directory Gulp just completely random generated exception TypeError: Invalid Version: undefined

.

I'm wondering - why does Gulp require a local installation? What's the point of keeping copies of Gulp inside every project folder (other than wasting hard drive space)? And is there a way to install and use Gulp only globally?

+3


source to share


1 answer


Well, I think so, if another developer clones your project and runs it npm install

, it will automatically install gulp for it, because package.json

nothing says they should have gulp. I think gulpfile.js

it would be obvious if they saw it, but it's always good to be wrong on the side of helping future developers.

Also, check this answer :



When a tool is installed globally, it will be used by the user as a command anywhere, including outside of node projects. Global installations for a node project are bad because they make deployment more difficult.

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

+1


source







All Articles