2

I have a project structure

|-app
   |-...
|-libs
|- package.json
|- index.html

I want the node_modules folder to be inside 'libs' folder. Like this-

|-app
   |-...
|-libs
   |-node_modules
       |-angular
       |-...
|- package.json
|- index.html

Is there any way to set configuration for this. so that next time I install any package, that will be dependency will directly go to that folder.

Anita
  • 2,352
  • 2
  • 19
  • 30
  • I'm not sure if it can work, but can a symbolic link suit your needs ? – Seblor Aug 21 '17 at 11:49
  • duplicate of https://stackoverflow.com/questions/18974436/change-node-modules-location – Aabid Aug 21 '17 at 11:53
  • If you CD into the libs folder when you do `npm install` it should install packages into that node_modules folder. Only problem is, doing an `npm init` inside your root isn't going to work. – Keith Aug 21 '17 at 12:10

1 Answers1

0

just cd into the folder and run npm init. That will create package.json file. Then you can add packages which will be installed in node_modules inside that folder.

jstice4all
  • 1,878
  • 4
  • 22
  • 33
  • 1
    I think OP wants to change the node_modules folder without changing the path when requiring the modules. – Seblor Aug 21 '17 at 11:48