Adam Patterson
Adam Patterson

Reputation: 689

Is it possible to centralize the Grunt modules?

I have recently started using grunt for well, running tasks. It seems faster at compiling and concatenating my JS and LESS. It also does a great job of watching for Photoshop Image assets and moves them/process them as needed.

I didn't give it much thought until I accidentally uploaded the node_modules folder and noticed that it was about 80mb.

Is this really the case? That if I were to have 10 projects based off the same grunt task that I will have almost 800 mb of space used up by 10 identical copies of the grunt-contrib?

I am not a Ruby guy but was under the impression that Gems were installed at a central point and available to other apps on the system.

Upvotes: 0

Views: 183

Answers (1)

Jordan Kasper
Jordan Kasper

Reputation: 13273

You can install Grunt plugins globally, just use the -g flag: npm install -g grunt-contrib-uglify ... However, the point of installing them in the project using the package.json file is that any other developer that wants to run/test/build the code need only run npm install in the project directory to install all dependencies. If you go the global route, then each developer will have to individually run npm install -g plugin-name for each one that is required - a very time-intensive (and annoying) process.

That said, if you are using source control (you are, right? ;)) then you should not commit your node_modules directory, only commit your package.json file. This is for many reasons, not the least of which is that those dependencies take up a lot of space (as you mention) and can be re-downloaded any time the project is pulled down on a new machine.

Upvotes: 1

Related Questions