1

I am coding a lot of individual plugins for my websites and I am using grunt to manage the final distribution of them. I'm used to write grunt.loadNpmTasks to import a specific plugin from the node_modules directory right into my Gruntfile performing the tasks.

However, in order to do that, i always npm install <package> --save-dev to make the plugin available in the specific plugin i am coding. But as they are dozens of plugins i am maintaining now, i found out the node_modules directories are growing quite bigger, and my backup gets more and more slowly as the node_modules directories are full of files.

Is there a way to centralize the plugins ? so I can reunite all the node_modules directories in one ? and tell grunt where this central repository stands as to load a particular plugin ?

edit: I tried to install grunt-contrib-less globally (-g) for the test, but it still persist to say Local Npm module "grunt-contrib-less" not found. Is it installed?

vdegenne
  • 12,272
  • 14
  • 80
  • 106
  • 1
    possible duplicate of http://stackoverflow.com/questions/16738177/grunt-possible-to-relocate-node-modules-for-plugins – Irvin Lim May 27 '15 at 21:32
  • in other words, no. I also personally wished it was possible, though. – Irvin Lim May 27 '15 at 21:33
  • Could you have a node_modules folder in one place, and then symlink it into the rest? never tried. – Kevin B May 27 '15 at 21:36
  • @KevinB I am using wind*ws right now though – vdegenne May 27 '15 at 21:37
  • windows has the same functionality, just under a different name. If only i could remember what it's called... – Kevin B May 27 '15 at 21:38
  • @KevinB not wrong, but i don't really like that because it sounds more like a trick. I wished this functionality was directly available as a js directive.. but still thanks for your support – vdegenne May 27 '15 at 21:40

1 Answers1

0

I haven't tested this. but it's worth trying. Instead of using grunt.loadNpmTasks try using load-grunt-tasks.

You should use the config option which allows you to specify the path of your pacakge.json.

require('load-grunt-tasks')(grunt, {config: '../package'});
Rachid
  • 812
  • 6
  • 7
  • it says, **cannot find the 'load-grunt-tasks' module** – vdegenne May 29 '15 at 09:00
  • `npm install --save-dev load-grunt-tasks`. You will ended up with two `package.json` files. The first one is your original `package.json` file which will host your local `grunt` and `load-grunt-tasks` (and allows you to run grunt), the second one is the one that will include all the other modules an is being referenced in your load-grunt-tasks `config` option. – Rachid May 29 '15 at 13:56