I'm developing a React App and everything works fine during npm start
. After I do npm run build
and run serve -s build
under the build folder, the terminal told me it's serving but when I checked out http://localhost:5000/
, it was
404 The requested path could not be found
Then I installed live-server and run live-server
under the build folder, the App worked fine again. But I don't understand why serve -s build
was not working properly.
Any ideas?
This doesn't work because you're running the command from inside the build folder already.
If you run serve --help you can see the usage documentation for this command. The serve command accepts an input of folder_name for the files it should serve. If no folder is specified it will serve the folder that you are running the command in (which is why Gabriele's response above solved your problem). You could run the serve -s build command from the parent folder that contains the build folder and it would also work.
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