How can I run export NODE_OPTIONS=–openssl-legacy-provider in Webpack script?

I have webpack script that triggers build

"buildProd": "webpack --config webpack.config.js --mode=production --display-error-details"

But it fails with error

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

I can fix this error manually typing

export NODE_OPTIONS=--openssl-legacy-provider

and all works fine

But I need to export NODE_OPTIONS in script for CI.
Is there any way to set NODE_OPTIONS in webpack script?

>Solution :

Use the env tool:

"buildProd": "env NODE_OPTIONS=--openssl-legacy-provider webpack --config webpack.config.js --mode=production --display-error-details"

Alternatively, set the option in your CI provider’s (you’re not telling us what you’re using, so I can’t help more specifically) environment variable settings.

Leave a Reply