I have successfully build the react Application. I am a bit confused what to do after build. serve is not working. also please answer what to do with server.js file in react project and how it helps in deployment
my application is running properly on local. I want it to run on my domain also.
npm serve is installed globally please click here to see the image
To solve the error "react-scripts is not recognized as an internal or external command, operable program or batch file", open your terminal in your project's root directory and install the react-scripts package by running npm install react-scripts and clear your npm cache if necessary. Copied!
In the “Settings” section click on the “Show advanced settings” Under the the “Privacy” click on the “Content settings”. When the dialog window opens, look for the “JavaScript” section and select “Allow all sites to run JavaScript (recommended)”. Click on the “OK” button to close it.
For your React app, you'll have to drag and drop the build folder onto the Netlify Dashboard. Run npm run build beforehand to deploy the latest build. You can also connect GitHub, GitLab, or Bitbucket, depending on where your project is stored. This allows automatic deployment whenever you push your changes.
I know that running npx serve -s build
should work. I had the same problem as you. The npx command works for me. If you have npx problems, check your version of nodejs. I'm running 10.16.2 (so that we're on the same page). https://www.npmjs.com/package/serve
The rest of your question is relative to the rest of your set up. I don't have a server.js file of my own (there are some node_module server.js files, is that what you mean)?
As I understand a create-react-app, npm run start
will allow you to run your application locally. I don't need serve -s build
for that.
I used an amplify create react app. For an amplify application, I just run amplify publish
and my application's build directory is sent to an S3 bucket for me. If you don't have that configuration, and you want the quick and dirty answer... just take the contents of your build directory in your react application and drop those files on your web server. That should get you 90% of the way there (mind the default page that renders).
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