I am using react-scripts
and successfully ran npm run build
to generate the build
folder.
I then went to serve it locally by using the serve npm package by running serve -s build
.
serve
then runs on port 5000, which is good.
When I go to access the page at localhost:5000
the page just stalls out and the following error is in the console main.975cb3de.js:1 Uncaught SyntaxError: Unexpected token <
.
I open the main.975cb3de.js
file in the console and it is trying to serve the index.html
file.
If I empty browser cache and reload the page then it loads fine. This happens every time I run a build.
I have a suspicion that there is a configuration in the serve
library but not too sure.
Any thoughts on why it tries to serve HTML first time around and how to fix this?