node.jsreact-nativemetro-bundlerbitrise

in Bitrise node.js Failed to construct transformer: Error: error:0308010C:digital envelope routines::unsupported React Native


whenever i try to build my react native app it is giving below mentioned error in bitrise virtual machine (apple silicon, silicon node default version is 18). but when i try to build using my local machine (apple intel, intel node default version is 16) it is working perfectly fine.

enter image description here

getting below error:

Failed to construct transformer:  Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at stableHash (/Users/vagrant/git/node_modules/metro-cache/src/stableHash.js:19:8)
    at Object.getCacheKey (/Users/vagrant/git/node_modules/metro-transform-worker/src/index.js:593:7)
    at getTransformCacheKey (/Users/vagrant/git/node_modules/metro/src/DeltaBundler/getTransformCacheKey.js:24:19)
    at new Transformer (/Users/vagrant/git/node_modules/metro/src/DeltaBundler/Transformer.js:48:9)
    at /Users/vagrant/git/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').
TypeError: Cannot read properties of undefined (reading 'transformFile')
    at Bundler.transformFile (/Users/vagrant/git/node_modules/metro/src/Bundler.js:48:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.transform (/Users/vagrant/git/node_modules/metro/src/lib/transformHelpers.js:101:12)
    at async processModule (/Users/vagrant/git/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:18)
    at async traverseDependenciesForSingleFile (/Users/vagrant/git/node_modules/metro/src/DeltaBundler/traverseDependencies.js:131:3)
    at async Promise.all (index 0)
    at async initialTraverseDependencies (/Users/vagrant/git/node_modules/metro/src/DeltaBundler/traverseDependencies.js:114:3)
    at async DeltaCalculator._getChangedDependencies (/Users/vagrant/git/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:164:25)
    at async DeltaCalculator.getDelta (/Users/vagrant/git/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:94:16)
    at async DeltaBundler.buildGraph (/Users/vagrant/git/node_modules/metro/src/DeltaBundler.js:50:5)
info Run CLI with --verbose flag for more details.

I tried the solution in the below link: node.js Failed to construct transformer: Error: error:0308010C:digital envelope routines::unsupported React Native Most of them suggesting to downgrade node version to 16, but i dont want to downgrade my node version since when i build in virtual machine i will not be able to downgrade node version.

also tried solution from below link: Error: error:0308010C:digital envelope routines::unsupported (Node.js v19.4.0) still it didnt work.

Any help would be appreciated. Thank you


Solution

  • Try this solution fir iOS builds

    set -e
    export NODE_OPTIONS=--openss1-legacy-provider # add env variable here
    WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
    REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"
    
    /bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"