Reputation: 1241
I created a ReactJS application using create-react-app, and worked on development. Now I am trying to deploy to a server on DigitalOcean, following a video tutorial.
During the video, he used a ready made example application. The only difference he did was to use pm2 start app.js
instead of npm start
Doing the same, pm2 showed the file is running, but when accessing the url, not working.
How do I do this step? I tried running npm build
and tried the same steps with no success.
Edit: npm run build
Please note that I am a beginner, and this is my first time trying to go to production.
Upvotes: 0
Views: 1243
Reputation: 914
1. install serve and pm2 packages globally on the system/server
npm install -g serve
npm install -g pm2
2. run the following command to create a production build of your app
npm run build
3. run the following command to deploy the app
pm2 serve <build folder path> <port> --spa
above command example
pm2 serve build 8082 --spa
4. Check the status of the application following command in the shell.
pm2 list
PM2 can serve static files very easily with the pm2 serve feature. It supports serving raw files from a specified folder or you can serve a SPA (Single Page Application) with it.
Upvotes: 2