I'm suddenly having issues with production versions of my react apps. They work fine in development, however when I build them, I get a console error:
/static/css/main.f6418f8a.chunk.css:1 Failed to load resource:
net::ERR_FILE_NOT_FOUND
1.13eeb203.chunk.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
main.1e6014ca.chunk.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
/favicon.ico:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
This error was received after the following commands:
create-react-app whatiswrong
npm run build
Then open the index.html in my browser like I would for any other react apps I've built.
You need to add "homepage": "./"
to your package.json.
From: https://github.com/facebook/create-react-app/issues/6275#issuecomment-457813277
"homepage":"path\to\your\project\build\"
npm run build
.The issue here was when you run the npm run build command without the homepage entry added in your package.json,it is built assuming that the project directory (where you are running the command) is hosted at server root.
screen-shot commandline
D:\git_repo\my-app>npm run build
> [email protected] build D:\git_repo\my-app
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
44.57 KB build\static\js\main.8a29685f.js
**The project was built assuming it is hosted at root directory.
You can control this with the homepage field in your package.json.**
The build folder is ready to be deployed.
D:\git_repo\my-app>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With