Skip to content

Instantly share code, notes, and snippets.

@arashmad
Created February 14, 2021 09:26
Show Gist options
  • Save arashmad/30059c8e52d150d91ab25e186bab7045 to your computer and use it in GitHub Desktop.
Save arashmad/30059c8e52d150d91ab25e186bab7045 to your computer and use it in GitHub Desktop.
build react-node-express project using yarn
// In React JS project go to package.json
// Inside the 'scripts' block, change
"start":"react-scripts start"
// to
"start":"react-scripts build && (cd backend && yarn start)",
// in which, backen is the root directory of node-express app
// and add
"start-client": "react-scripts start", //starts react app on port=3000
// now in node-express root directory, open server.js (maybe app.js)
// make this changes
const path = require('path');
app.use(express.static(path.join(__dirname, "..", "build")));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment