I've run the following commands:
create-react-app myApp
cd myApp
npm run build
copy build folder into server

What to do?
This seems to be more of a configuration issue with your application rather than CRA itself.
On that note, you need to make sure your web server is serving static files from the proper directory (express makes this easy, though we don't assume your backend).
If you would like to develop, you should be using the npm start command instead.
Cheers!
You might also find deployment instructions helpful: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment
But yes, if you just mean to start developing you need npm start instead.
Also when you run npm run build you should see exact instructions for serving those files on the terminal screen. Have you had a chance to try following them yet? Did you have any issues doing so?
I've tried running the build via XAMPP locally, I copied the build folder into the htdocs and then started the server then went into localhost/build when I go to localhost/build/static/js/main....js it shows the file.
Do I need a node/express server to be able to run the app?
and yes I've run npm start to develop and it works nicely.
@jsantana90 copy the contents of the build directory into htdocs instead of the directory itself; you need to do this until https://github.com/facebookincubator/create-react-app/issues/1094 is resolved.
e.g. instead of htdocs\build\index.html and htdocs\build\static\js\main*.js you want htdocs\index.html and htdocs\static\js\main*.js.
@Timer that worked, thank you!
No problem, @jsantana90. Let us know if you're having any other issues. 馃槃
Is there a way to override the need to specify the URL for the package to have CRA serve on a sub-route? Everything's being developed on a semi-random localhost port, which I would prefer not to encode into the package.json...
@pretentiousgit we actually ignore the specific url and only use the sub-route; so the arbitrary port is fine for homepage.
Hello,
I'm trying to deploy and create react app. I build it and then I served it on my local machine and everthing works fine.
Now I tried to pass the contenent of the build folder to a webserver (192.168.0.91) which resides on a PLC (SAIA PLC) in my local network
If I point to http://192.168.0.91/index.html
i get the following error :
http://192.168.0.91/static/css/main.c90e76c6.css 400 (Bad Request)
If in my browser I point directly to http://192.168.0.91/static/css/main.c90e76c6.css
the answer is: "Your request has bad syntax."
For testing purposes i created a copy of that file and renamed it "main.c90.css"
If I point to that file now in the browser "http://192.168.0.91/static/css/main.c90.css"
the file gets downloaded as expected.
So in my humble opinion the problem seems to reside in web server itself, like some issues with lenghts of filenames or something like this, but I just don't know enough about servers ecc. I would really need to know if I can deploy my react projects on that kind of PLC Web server or not.
Please if somebody can help me with that I would be very grateful
Most helpful comment
@jsantana90 copy the contents of the build directory into htdocs instead of the directory itself; you need to do this until https://github.com/facebookincubator/create-react-app/issues/1094 is resolved.
e.g. instead of
htdocs\build\index.htmlandhtdocs\build\static\js\main*.jsyou wanthtdocs\index.htmlandhtdocs\static\js\main*.js.