Skip to content

Commit

Permalink
build(ui): export 'NODE_OPTIONS=--openssl-legacy-provider' if node > 16
Browse files Browse the repository at this point in the history
Updates UI build script to check the version of node available, parse
the major version out, and then set the legacy openssl provider node
option if the installed node version is above 16. Resolves several CI
build issues with images that use node v20+. Example:

https://github.com/prometheus/promlens/actions/runs/11749125293/job/32738433538?pr=149

```bash
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
/app/app/node_modules/react-scripts/scripts/build.js:19
  throw err;
  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:138:10)
    at module.exports (/app/app/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/app/app/node_modules/webpack/lib/NormalModule.js:417:16)
    at /app/app/node_modules/webpack/lib/NormalModule.js:452:10
    at /app/app/node_modules/webpack/lib/NormalModule.js:323:13
    at /app/app/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /app/app/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/app/app/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /app/app/node_modules/babel-loader/lib/index.js:59:103
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v20.5.1
make: *** [Makefile:36: build-ui] Error 1
!! The base builder docker image exited unexpectedly: exit status 2
```

Signed-off-by: TJ Hoplock <[email protected]>
  • Loading branch information
tjhop committed Nov 9, 2024
1 parent 86f59e8 commit d3529ff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/build_ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ then
export CYPRESS_CACHE_FOLDER=${npm_config_cache}/cypress_cache
fi

node_version="$(node --version)"
node_version="${node_version%%.*}" # v22.9.0 -> v22
node_version="${node_version:1}" # v22 -> 22
if [[ $node_version > 16 ]]; then
echo "Detected node version greater than 16"
echo "Exporting 'NODE_OPTIONS=--openssl-legacy-provider'"
echo "https://github.com/prometheus/promlens?tab=readme-ov-file#building-from-source"
export NODE_OPTIONS=--openssl-legacy-provider
fi

cd app
npm i
npm run build

0 comments on commit d3529ff

Please sign in to comment.