I am going to build my boilerplate for React and node, the root folder structure is look like this
- (root level)
- client - src
- public
- package.json
- ...
- package.json
- server.js
- node_modules
In my package.json of root folder, I have some code like:
"start": " nodemon ./server.js | react-scripts start ./client"
When I run npm start
, only the react app is build and run, the node app doesn't run. Any tips for how to just run npm start
and both React and node app run?
By the way, I have set "proxy": "http://localhost:5000/"
in the client's package.json. The server.js has code like
const port = process.env.PORT || 5000;
// console.log that your server is up and running
app.listen(port, () => console.log(`Listening on port ${port}`));
Thank you.
Solution:
Thanks so much for rodrigoap replies.
I use the concurrently package to solve my problem.
My package.json
in my root folder look like this and work:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "concurrently \"cd client && npm run start\" \"npm run start\"",
"start": "nodemon ./server.js"
},