GitHub Action running npm build fails on warnings

On a new GitHub Action I’ve added on a React project, the npm run build is failing because apparently GitHib Actions treat warnings as errors:

Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.

Failed to compile.

Following advice on questions to this post, adding CI=false to the ‘npm run build’ script in package.json turns off this behavior:

    "predeploy": "CI=false && npm run build",

GitHub Action npm i fails when package.json includes fsevents

I’ve added a GitHub Action to a project, and when it runs on a push I get this error:

Run npm ci
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-09-11T23_52_20_527Z-debug-0.log
Error: Process completed with exit code 1.

fsevents is installed/added when doing ‘npm i’ as a dependency when building on MacOS, but it is MacOS specific, and since it’s included in my package.json it’s causing the build on GitHub to fail. Apparently according to this post, it can be optionally included on platforms where it’s available/needed by moving it from the dependencies section in package.json to optionalDependencies instead:

  "optionalDependencies": {
    "fsevents": "^2.3.2"
  }

This resolved my issue, my GitHub Action now runs.