Posts

Showing posts with the label deploy

20/03/2021 - deploy node app to heroku

this is a react app run on express server app. backend and frontend. tidying up the directories and pre production code server js // const __dirname = path.resolve(); if ((process.env.NODE_ENV = 'production')) {   app.use(express.static(path.join(__dirname, 'my-app/build')));   app.get('/', function (req, res) {     res.sendFile(path.join(__dirname, 'my-app', 'build', 'index.html'));   }); } package json  "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix "<frontend folder>" && npm run build --prefix "<frontend folder>" procfile web: node src/server.js .gitignore /nodemodules .env //test run your app before deploy .env  NODE_ENV=production //terminal cd <frontend folder> npm run build cd .. cd <backend folder> npm run start //change back to development //deploying to heroku 1. push to git repo 2. install heroku cli 3. run heroku command to create app and...