ani
ani

Reputation: 323

Should I make multiple node_modules folders for multiple files or use one?

I am starting a JavaScript project and its parent directory contains 2 folders: client and server. Both of these will require Javascript packages but I'm confused as to whether I should make a node_modules folder in each of them for their respective dependencies or whether I should create only one and install all the packages there. Basically what I'm asking is whether I should do this:

enter image description here

or this:

enter image description here

Upvotes: 2

Views: 2385

Answers (1)

Apoorva Chikara
Apoorva Chikara

Reputation: 8783

I should make a node_modules folder in each of them for their respective dependencies or whether I should create only one and install all the packages there.

As you have client- Frontend and server - Backend which are two different side of things and they will have their own dependencies with package.json. You might be installing some specific packages which only works on browser and same for server-side environment.

It is good to segregate both the environment to keep dependencies separate. You should check this link to check out things in details.

Upvotes: 2

Related Questions