node_modules location in development stage

90 views
Skip to first unread message

Peter Remec

unread,
Jan 13, 2017, 7:52:22 AM1/13/17
to Angular

Recently I started with Angular 2 app development and I came across some problem. I have multiple projects that use certain node modules and I installed those modules with npm install in project folder. But then I started thinking: If I have a lot of projects and install node modules for each of those projects, it requires quite a lot of disk space and there are some node modules installed multiple times (in a multiple projects). So I tried to find a way to install node modules in some common folder in order to make that folder some kind of library that my projects use. But there's another problem that comes to my mind: What if different projects require different versions of the same module? How can I install multiple module versions in the same folder?


Maybe I'm thinking completely the wrong way, so I'm asking for your solutions of my problem. Is there any common way of handling node modules in development stage? Does each project have own node modules folder or is there some common folder to ? What's the most common approach (if there is one)?


Thanks!

Sander Elias

unread,
Jan 13, 2017, 8:16:17 AM1/13/17
to Angular
Hi Peter,

The common approach is to have the node_modules folder in every project folder. Keep everything you need for 1 project next to each other. prevent versions from mixing in.
If you are pressed for disk-space (not common on dev machines) you can delete node_modules in the inactive projects. If you want to do that, you might want to switch to yarn for package management. 

Regards
Sander
Reply all
Reply to author
Forward
0 new messages