I'm working on a Next.js project, and I am trying to use Github Actions for CI/CD. I am using a DigitalOcean droplet and it is able to build the app easily by doing manually. But I'm not sure why this is not happening on GitHub action.
Error in text format.
err: npm WARN EBADENGINE Unsupported engine {
err: npm WARN EBADENGINE package: 'next@13.3.2',
err: npm WARN EBADENGINE required: { node: '>=16.8.0' },
err: npm WARN EBADENGINE current: { node: 'v12.***.9', npm: '8.5.1' }
err: npm WARN EBADENGINE }
out: up to date, audited 21 packages in 828ms
out: 3 packages are looking for funding
out: run `npm fund` for details
out: found 0 vulnerabilities
out: > build
out: > next build
err: /var/www/frontend-test/node_modules/next/dist/build/index.js:394
err: ...pageKeys.app ?? []
err: ^
err: SyntaxError: Unexpected token '?'
err: at wrapSafe (internal/modules/cjs/loader.js:915:16)
err: at Module._compile (internal/modules/cjs/loader.js:963:27)
err: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
err: at Module.load (internal/modules/cjs/loader.js:863:32)
err: at Function.Module._load (internal/modules/cjs/loader.js:708:14)
err: at Module.require (internal/modules/cjs/loader.js:887:19)
err: at require (internal/modules/cjs/helpers.js:74:18)
err: at Object.<anonymous> (/var/www/frontend-test/node_modules/next/dist/cli/next-build.js:15:55)
err: at Module._compile (internal/modules/cjs/loader.js:999:30)
err: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
out: Use --update-env to update environment variables
out: [PM2] Applying action reloadProcessId on app [frontend-test](ids: [ 0 ])
out: [PM2] [frontend-test](0) ✓
==============================================
✅ Successfully executed commands to all host.
==============================================
My server is using latest Node.
The steps when performed manually.
Npm and node version on server.
This is the content of my YAML file.
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: npm install
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Build
run: npm run build
- name: Deploy to Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.SSHKEY }}
script: |
cd /var/www/frontend-test
git fetch
npm install
npm run build
pm2 reload frontend-test
Does anyone know what might be causing this issue, and how I can fix it?