'Getting a blank screen when deploying react app to heroku
file structure imageOnce the app is built, I am only getting a blank screen on Heroku.
My root package.json has the following scripts:
"scripts": {
"start": "node index.js",
"heroku-postbuild": "cd client && npm install --only=dev && npm install && npm run build"
},
I defined the engines with my versions of node and npm.
I also added "homepage": "." in my package.json
In my server index.js I have the following:
if(process.env.NODE_ENV === "production"){
app.use(express.static(path.join(__dirname, "client/build")));
}
app.get("*", (req,res)=>{
res.sendFile(path.join(__dirname+ "client/build", "index.html"))
})
Finally, here is the heroku logs --tail:
2022-03-30T21:52:08.924292+00:00 heroku\[web.1\]: State changed from up to starting
2022-03-30T21:52:09.000000+00:00 app\[api\]: Build succeeded
2022-03-30T21:52:09.821908+00:00 heroku\[web.1\]: Stopping all processes with SIGTERM
2022-03-30T21:52:09.867067+00:00 app\[web.1\]: Going down, terminating child processes...
2022-03-30T21:52:10.008660+00:00 heroku\[web.1\]: Process exited with status 0
2022-03-30T21:52:16.272272+00:00 heroku\[web.1\]: Starting process with command `bin/boot`
2022-03-30T21:52:17.144106+00:00 app\[web.1\]: ls: cannot access '/app/build/static/js/*.js': No such file or directory*
2022-03-30T21:52:17.144325+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-
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
