I am pretty new to Gulp and I've got a question: should I install gulp plugins (such as gulp-sass or gulp-imagemin) locally or globally? In examples around the web people mostly do it locally (with --save-dev
option). As I understand, by doing so the modules are stored in the local node_modules
folder, added in the local package.json
as devDependencies and can be referenced to in the local gulpfile.js via require()
. So, if I need to install the same modules for another project I work on, it may be accomplished by copying package.json
to a new project's folder and typing in npm install
in a command line tool (after getting to the project's folder). Fine.
But what if I, as a regular gulp user, don't have plans to upload and share my stuff on the npm space and not interested in maintaining devDependencies, can I in this case just install gulp plugins globally like npm install -g gulp-sass
? Will they be found through a global path in my system? Is it an option on the whole, if I don't want to bother myself to copy package.json
, run npm install
every time I create a new project or have multiple copies of the same modules scattered around on my disk?
For plugins that you are using via gulp, what you have to do is install them locally to the project. Although you have to install gulp itself globally and locally, to run the file and then for the project to pick up the gulp based commands and functions.
The reason you should install the plugins via npm
locally is so that it is specific to the project, for example if you then went to upload this project to your server or host on github then you would have to then go and have to globally install all of your packages again. If they are saved, they exist in your packages.json
, this is so that when you go to run npm install
to install all the packages for said project npm knows what to install.
If I can further clarify anything let me know.