Grunt - folder node_modules outside the project

0

Well, I'm starting GruntJS, my node_modules folder has 50MB, so for every project, it gets bad.

I would like to know if you can leave a default node_modules folder in one place to use in all projects without having to stay within the project's root.

Thank you

Example:

My front-end project today:

   nome-do-projeto
   ---node_modules(50mb)
   ---assets
      ---sass
       ---js
   ---build
       ---css
       ---js

I would like the node_modules folder to have been outside the project root.

    
asked by anonymous 28.08.2014 / 03:14

2 answers

1

Dude, if you frequently use certain modules like Express, Grunt or Gulp, you can install them as global modules:

npm install -g nome_modulo

Within your project when you are loading a dependency, Node will look for your module within your project (node_modules), if it does not find it it will look in the global node_modules folder.

Node is not usually version dependent. A good practice is you create a file called package.json and define its dependencies there, when someone else downloads your project, you just need to run the command:

npm install

So the node downloads and installs the dependencies of your project.

References (in English): package.json node_modules

    
11.09.2014 / 03:05
0

A tip that might work but did not test:

$ cd <global-modules-path>/node-google-timezone # vai para o diretório global do package
$ npm link                                      # cria um link global
$ cd ~/projects/my-node-project                 # vai para o diretório do seu projeto
$ npm link                                      # link-install do package

Reference: NPM link

    
28.08.2014 / 19:07