khdeveloperj
khdeveloperj

Reputation: 5

best structure for MERN stack web App (nodejs & express & mongoDB as a server and Reactjs as a Client?

I have a MERN stack app whats the best structure for it? take in account i will use the express API later for a Mobile application i have this structure now (main folder App inside it Client and server folder every folder has it own node_modules folder package.json and package-lock.json or should i have only one node_modules folder package.json and package-lock.json for both in the main App? and how to push them to Heroku should i push every app separately or both together as a one app and how?

Upvotes: 1

Views: 990

Answers (2)

Faraz
Faraz

Reputation: 55

Two seperate 'Backend' and 'Frontend' folders inside a 'root' folder. Those two folders should have their own seperate 'node_modules' folder and 'package.json'. Here's a more detailed answer

Upvotes: 0

Daniel
Daniel

Reputation: 2531

If you going for then mono-repo (single git repository for the whole project) approach its a good practice to keep modules separate. Each one with its own dependencies.

The most common solution is a top-level tooling mechanism that keeps each module separated but still have the ability to install and build all the projects. Many developers are using lerna to manage multiple node projects.

Upvotes: 1

Related Questions