I tried to deploy my react app to the droplet in the digital ocean using Github action, but I faced a problem when Github Action try to run the build command, it always throws an error:
Run npm run build
npm ERR! Missing script: "build"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! /home/gli/.npm/_logs/2022-11-24T06_58_48_588Z-debug-0.log
Error: Process completed with exit code 1.
My package.json file, I do not know why since I also have a build script in the package.json file as well.
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Github Action node.js.yml
name: Node.js CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: cd frontend
- run: npm i
- run: npm run build # fail here......:(
- run: cd ..
- run: pm2 stop 0
- run: pm2 start 0
- run: pm2 save
- run: sudo service nginx restart
Note: Other commands are running fine only the run: npm run build
is fail.
Does anyone know what the problem is? I would appreciate your help and advice.