electrode-io / electrode-native

A platform to ease integration&delivery of React Native apps in existing mobile applications
https://native.electrode.io
Other
723 stars 113 forks source link

Failed to construct transformer: Error: error:0308010C:digital envelope routines::unsupported (Node.js 17+) #1879

Open friederbluemle opened 1 year ago

friederbluemle commented 1 year ago

When using Node.js 17+, multiple React Native related commands will fail with the following error:

✖ Failed to construct transformer:  Error: error:0308010C:digital envelope routines::unsupported
✖     at new Hash (node:internal/crypto/hash:71:19)
✖     at Object.createHash (node:crypto:133:10)
✖     at stableHash (/tmpdir/node_modules/metro-cache/src/stableHash.js:19:8)
✖     at Object.getCacheKey (/tmpdir/node_modules/metro-transform-worker/src/index.js:593:7)
✖     at getTransformCacheKey (/tmpdir/node_modules/metro/src/DeltaBundler/getTransformCacheKey.js:24:19)
✖     at new Transformer (/tmpdir/node_modules/metro/src/DeltaBundler/Transformer.js:48:9)
✖     at /tmpdir/node_modules/metro/src/Bundler.js:22:29
✖     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'
✖ }
✖ error Cannot read properties of undefined (reading 'transformFile').

This is due to a change in Node.js, and the fact that we still rely on the react-native-cli. https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported

The longer term fix is to remove the dependency on react-native-cli.

The short term workaround is to set this environment variable:

export NODE_OPTIONS=--openssl-legacy-provider