Wasn’t sure which category would be best but basically I am curious about best practice for file management in an App that uses React and Node.js.
Basically it is a personal budgeting application that uses React for front end and Node for backend (MongoDB for the database).
This is the file tree.
—client
node_modules
public (index.html)
src (App.js, index.js, styles.css)
package.json
.gitattributes
— server
.gitignore
node_modules
package.json
server.js
So basically no root package.json. Just two files with client and server. I have dual terminals up and to run it npm start both at the same time and they can connect as separate servers.
But now I want to host this for myself on Heroku but without a root package it is difficult. Is my way even feasible? How should I restructure my files?
Sorry for the confusing post but I appreciate any feedback.
I would need to research more about hosting the client and server separately. Admittedly, this is my first time hosting a web app I have written myself.
I restructured my files to be so that root is the server.js and in my package.json file there is “start: node server.js” so that the server.js file starts up first and then loads the react files when app.get(“/”). This crashes heroku though.
I’ll look into hosting separately.
THanks for the reply.