Deploy Reatjs app on Heroku
1. React JS app
npm install -g create-react-app
create-react-app my-app
cd my-app
git init
heroku create -b https://github.com/mars/create-react-app-buildpack.git
git add .
git commit -m "react-create-app on Heroku"
git push heroku master
heroku open
OR if you already have app created then add mars/create-react-app then set
heroku buildpacks:set mars/create-react-app
2. If following error coming then set bundle path:
ls: cannot access '/app/build/static/js/*.js': No such file or directory
2019-12-23T07:49:22.901124+00:00 app[web.1]: Error injecting runtime env: bundle not found '/app/build/static/js/*.js'. See: https://github.com/mars/create-react-app-buildpack/blob/master/README.md#user-content-custom-bundle-location
heroku config:set JS_RUNTIME_TARGET_BUNDLE='/app/dist/*.js'
Make sure your bundle into directory /app/dist OR if you have your bundle into other directory then set other directory path.
3. Add static.json
{
"root": "dist/",
"routes": {
"/**": "index.html"
}
}
3. Add static.json
{
"root": "dist/",
"routes": {
"/**": "index.html"
}
}
Enumerating objects: 112, done.
ReplyDeleteCounting objects: 100% (112/112), done.
Delta compression using up to 4 threads
Compressing objects: 100% (101/101), done.
Writing objects: 100% (112/112), 1.40 MiB | 212.00 KiB/s, done.
Total 112 (delta 37), reused 73 (delta 5)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> React.js (create-react-app) multi app detected
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-multi.git
remote: =====> Detected Framework: Multipack
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
remote: =====> Detected Framework: Node.js
remote: parse error: Unmatched '}' at line 57, column 1
remote: ! Unable to parse package.json
remote:
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile React.js (create-react-app) multi app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to coronatale.
remote:
To https://git.heroku.com/coronatale.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/coronatale.git'
Exclusive post. Thanks for sharing.
ReplyDeleteBest Freelance React Native App Developer
Hi, thanks for the blog!
ReplyDeletewhere should I run this: heroku config:set JS_RUNTIME_TARGET_BUNDLE='/app/dist/*.js' in the terminal or insert it in a specific file?
Thanks
Nice blog! I really loved reading through this Blog... Thanks for sharing such a very interesting post with us and keep blogging.
ReplyDeleteVisit our website-
web and app development
xamarin development company
ABP.io framework development
If you want to hire react js developer then Arka Softwares is leading reactjs development company that serves clients globally. Our reactjs development services have reached myriad startups and large enterprise customers of various industries.
ReplyDeleteXtreem Solution, a leading reactjs software development company serving clients worldwide, is the best place to find a reactjs developer. Our reactjs services have been used by many startups and large enterprises in a variety of industries.
ReplyDeleteNice article! Full of informative and meaningful facts. Your thoughts on Technology with detailed analytics is well narrated. I enjoyed reading your article.
ReplyDeleteWalmart call out number
qualitative vs quantitative research
Thanks for your information, it was really very helpful, Very Informative and well explained.
ReplyDeletetech write for us