'React craco build fails on dokku: Could not find a required file. Name: index.html
I try to deploy my react app (craco) on dokku and I get this strange error on build:
remote: -----> Build
remote: Running build
remote:
remote: > [email protected] build /tmp/build
remote: > craco build
remote:
remote: Could not find a required file.
remote: Name: index.html
remote: Searched in: /tmp/build/public
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! [email protected] build: `craco build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the [email protected] build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.YE1Rx/_logs/2021-12-21T22_16_52_564Z-debug.log
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: 2021/12/21 22:16:53 exit status 1
I found similar errors like this on SO but no answer could solve my problem.
Running the build script locally works just fine but when I deploy it I get this error.
my Scripts look like this:
"scripts": {
"start": "concurrently \"node Server/index.ts\" \"craco start\"",
"frontend": "craco start",
"backend": "node Server/index.ts",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",
"postinstall": "npm install --prefix Server && mv ./build/* ./Server/public"
}
why is it missing the index.html file? It is not in .gitignore file - I commited the public/index.html file to git and pushed it to dokku. I just can't understand what is going on here. My postinstall script installs the modules in ./Server (express.js api) and than moves the react build folder with all its content into ./Server/public where I want to serve them as static content.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|