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.

React app running locally failing with opensslErrorStack ERR_OSSL_EVP_UNSUPPORTED

I just started getting this error starting up my React app locally with ‘npm run start’ :

opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'

I recently installed nvm on my Mac to avoid needing sudo for running a ‘npm i -g’, and also apparently picked up the latest stable node version and not lts.

Running ‘nvm ls’ to see what version I have and what’s available:

> nvm ls
->      v17.3.0
         system
default -> node (-> v17.3.0)

According to https://nodejs.org/en/download/current/ 17.3.0 is the latest current and not lts. Answers to this related question suggested switching back to lts to avoid this change.

Following the nvm docs :

nvm install -lts
nvm use --lts

Now I’ve back at version 16.13.1, and my React app with ‘npm run start’ now starts as expected.