Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_OSSL_EVP_UNSUPPORTED, Command PhaseScriptExecution failed with a nonzero exit code #1051

Closed
techamit95ch opened this issue Aug 3, 2023 · 12 comments

Comments

@techamit95ch
Copy link

Hi I am using react native@0.67.5, it's an old project, but officially it's running

My node version is v18.17.0

And my openssl version : OpenSSL 3.0.10 1 Aug 2023 (Library: OpenSSL 3.0.10 1 Aug 2023)
And I am m1 MacBook Pro user.

and I am continuously getting this error.


 node /Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/amitchakraborty/Library/Developer/Xcode/DerivedData/VulcanEleven-fauzipknssuyavfknzrdbgfdkwla/Build/Intermediates.noindex/ArchiveIntermediates/VulcanEleven/BuildProductsPath/ReleaseProduction-iphoneos/main.jsbundle --assets-dest /Users/amitchakraborty/Library/Developer/Xcode/DerivedData/VulcanEleven-fauzipknssuyavfknzrdbgfdkwla/Build/Intermediates.noindex/ArchiveIntermediates/VulcanEleven/BuildProductsPath/ReleaseProduction-iphoneos/VulcanEleven.app --minify false
warning: the transform cache was reset.
                    Welcome to Metro!
              Fast - Scalable - Integrated


watchman warning:  Recrawled this watch 39 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2' ; watchman watch-project '/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2'`

Recrawled this watch 39 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2' ; watchman watch-project '/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2'`

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/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro-cache/src/stableHash.js:19:8)
    at Object.getCacheKey (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro-transform-worker/src/index.js:593:7)
    at getTransformCacheKey (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/DeltaBundler/getTransformCacheKey.js:24:19)
    at new Transformer (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/DeltaBundler/Transformer.js:48:9)
    at /Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/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/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/Bundler.js:48:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.transform (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/lib/transformHelpers.js:101:12)
    at async processModule (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:18)
    at async traverseDependenciesForSingleFile (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/DeltaBundler/traverseDependencies.js:131:3)
    at async Promise.all (index 0)
    at async initialTraverseDependencies (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/DeltaBundler/traverseDependencies.js:114:3)
    at async DeltaCalculator._getChangedDependencies (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:164:25)
    at async DeltaCalculator.getDelta (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:94:16)
    at async DeltaBundler.buildGraph (/Users/amitchakraborty/Desktop/Office/React_Native/defi11-react-native-v2/node_modules/metro/src/DeltaBundler.js:50:5)
info Run CLI with --verbose flag for more details.
Command PhaseScriptExecution failed with a nonzero exit code ,

I have reinstalled project several times, cleared node modes several time

I google tried to find solution although , there I found I have to add export NODE_OPTIONS=--openssl-legacy-provider in ~/.bashrc and ~/.zshrc, Which I did. It worked for react-native run-ios and react-native run-android

**but when I am trying to build from Xcode or I am trying to archive project for test flight I am getting previous error again **

Can you help me to resolve this issue?

Here is my package.json's dependencies

"dependencies": {
		"@biconomy/mexa": "2.0.35",
		"@coinbase/cbpay-js": "^1.6.0",
		"@craftzdog/react-native-buffer": "^6.0.5",
		"@ethereumjs/tx": "^3.3.2",
		"@gorhom/animated-tabbar": "2.1.1",
		"@gorhom/bottom-sheet": "^4",
		"@react-native-clipboard/clipboard": "^1.11.1",
		"@react-native-community/hooks": "^2.8.1",
		"@react-native-community/masked-view": "^0.1.11",
		"@react-native-community/netinfo": "^9.3.0",
		"@react-native-community/slider": "^4.4.2",
		"@react-native-firebase/analytics": "^12.9.3",
		"@react-native-firebase/app": "^12.9.3",
		"@react-native-firebase/dynamic-links": "^12.9.3",
		"@react-native-firebase/messaging": "^12.9.3",
		"@react-navigation/bottom-tabs": "^6.0.5",
		"@react-navigation/core": "^6.0.3",
		"@react-navigation/devtools": "^6.0.10",
		"@react-navigation/native": "^6.0.4",
		"@react-navigation/native-stack": "^6.6.1",
		"@react-navigation/stack": "^5.x",
		"@reduxjs/toolkit": "^1.8.5",

		"@shopify/flash-list": "^1.4.0",
		"@tanstack/react-query": "^4.13.0",
		"@tradle/react-native-http": "^2.0.1",
		"assert": "^1.5.0",
		"axios": "0.27.2",
		"base-64": "^1.0.0",
		"browserify-zlib": "^0.1.4",
		"buffer": "^4.9.2",
		"console-browserify": "^1.2.0",
		"constants-browserify": "^1.0.0",
		"crypto-js": "^4.1.1",
		"dns.js": "^1.0.1",
		"domain-browser": "^1.2.0",
		"ethers": "^5.5.2",
		"events": "^1.1.1",
		"https-browserify": "^0.0.1",
		"lodash.capitalize": "^4.2.1",
		"lodash.find": "^4.6.0",
		"lodash.isempty": "^4.4.0",
		"moti": "^0.20.0",
		"node-libs-browser": "^2.2.1",
		"path-browserify": "^0.0.0",
		"process": "^0.11.10",
		"prop-types": "^15.7.2",
		"punycode": "^1.4.1",
		"querystring-es3": "^0.2.1",
		"react": "17.0.2",
		"react-native": "0.67.5",
		"react-native-app-intro-slider": "^4.0.4",
		"react-native-bouncy-checkbox": "^3.0.2",
		"react-native-checkbox-reanimated": "^0.1.0",
		"react-native-code-push": "^7.0.4",
		"react-native-crypto": "^2.2.0",
		"react-native-device-info": "^10.0.2",
		"react-native-fast-image": "^8.5.11",
		"react-native-file-access": "^2.5.0",
		"react-native-flipper": "0.125.0",
		"react-native-gesture-handler": "2.9.0",
		"react-native-haptic-feedback": "^1.14.0",
		"react-native-inappbrowser-reborn": "^3.7.0",
		"react-native-keyboard-aware-scroll-view": "^0.9.5",
		"react-native-level-fs": "^3.0.1",
		"react-native-linear-gradient": "^2.6.2",
		"react-native-material-menu": "^2.0.0",
		"react-native-mmkv": "2.1.0",
		"react-native-modal": "^13.0.1",
		"react-native-os": "^1.2.6",
		"react-native-permissions": "^3.6.1",
		"react-native-popover-view": "^4.1.0",
		"react-native-quick-base64": "^2.0.5",
		"react-native-randombytes": "^3.6.1",
		"react-native-razorpay": "^2.3.0",
		"react-native-reanimated": "2.8.0",
		"react-native-rename": "^3.2.12",
		"react-native-responsive-fontsize": "^0.5.1",
		"react-native-safe-area-context": "^3.3.2",
		"react-native-screens": "3.9.0",
		"react-native-share": "^7.9.0",
		"react-native-snap-carousel": "^4.0.0-beta.6",
		"react-native-sound": "^0.11.2",
		"react-native-status-bar-height": "^2.6.0",
		"react-native-svg": "^12.1.1",
		"react-native-tcp-socket": "^6.0.2",
		"react-native-toast-message": "^2.1.5",
		"react-native-udp": "^4.1.7",
		"react-native-webview": "^11.26.0",
		"react-redux": "^8.0.2",
		"react-timer-hook": "^3.0.5",
		"readable-stream": "^1.0.33",
		"redux": "^4.2.0",
		"redux-flipper": "^2.0.0",
		"redux-persist": "^6.0.0",
		"stream-browserify": "^3.0.0",
		"string_decoder": "^0.10.31",
		"timers-browserify": "^1.4.2",
		"tty-browserify": "^0.0.0",
		"url": "^0.10.3",
		"util": "^0.10.4",
		"vm-browserify": "^0.0.4",
		"web3": "^1.6.1",
		"zustand": "^4.1.3"
	},
	"devDependencies": {
		"@babel/core": "^7.12.9",
		"@babel/plugin-transform-react-jsx": "^7.14.9",
		"@babel/runtime": "^7.15.4",
		"@react-native-community/eslint-config": "^2.0.0",
		"@types/crypto-js": "^4.1.1",
		"@types/fbemitter": "^2.0.32",
		"@types/lodash.capitalize": "^4.2.7",
		"@types/lodash.find": "^4.6.7",
		"@types/lodash.isempty": "^4.4.7",
		"@types/node": "^16.11.6",
		"@types/react": "17.0.18",
		"@types/react-native": "^0.66.11",
		"@types/react-native-razorpay": "^2.2.0",
		"@types/react-native-snap-carousel": "^3.8.5",
		"@types/react-redux": "^7.1.18",
		"@types/react-test-renderer": "^17.0.1",
		"babel-jest": "^26.6.3",
		"babel-plugin-module-resolver": "^4.0.0",
		"eslint": "^7.22.0",
		"eslint-config-prettier": "^8.3.0",
		"eslint-import-resolver-babel-module": "^5.1.2",
		"eslint-plugin-import": "^2.24.2",
		"eslint-plugin-jest": "^24.3.5",
		"eslint-plugin-prettier": "^4.0.0",
		"eslint-plugin-react": "^7.26.1",
		"eslint-plugin-simple-import-sort": "^7.0.0",
		"husky": "^7.0.0",
		"identity-obj-proxy": "^3.0.0",
		"jest": "^26.6.3",
		"lint-staged": ">=10",
		"metro-react-native-babel-preset": "^0.66.2",
		"patch-package": "^6.4.7",
		"prettier": "^2.4.1",
		"react-native-clean-project": "^4.0.1",
		"react-native-mmkv-flipper-plugin": "^1.0.0",
		"react-native-svg-transformer": "^1.0.0",
		"react-query-native-devtools": "^4.0.0",
		"react-test-renderer": "17.0.2",
		"rn-nodeify": "^10.3.0",
		"typescript": "^4.4.3"
	},

Here is the screen shot from xcode

Screen Shot 2023-08-03 at 07 44 44 AM

I am facing this issue for several day's , but 3month earlier I was't getting this type of issue

@techamit95ch techamit95ch changed the title Command PhaseScriptExecution failed with a nonzero exit code ERR_OSSL_EVP_UNSUPPORTED, Command PhaseScriptExecution failed with a nonzero exit code Aug 3, 2023
@nvdnvd00
Copy link

nvdnvd00 commented Aug 6, 2023

The same happen to me on 0.64.2 , I upgraded to 0.67.5, still got the issue.
I have another project run on 0.71.10 and no issue

  OS: macOS 13.4.1
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 1.34 GB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.5.0
    path: ~/.nvm/versions/node/v20.5.0/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 9.8.0
    path: ~/.nvm/versions/node/v20.5.0/bin/npm
  Watchman:
    version: 2023.07.24.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/admin/.rvm/gems/ruby-2.7.6/bin/pod```

@pmella16
Copy link

pmella16 commented Aug 29, 2023

hi, try add this in target -> build phases -> bundle react native code and images

export NODE_OPTIONS=--openssl-legacy-provider

image

@emilcieslar
Copy link

This issue is very likely related to this: https://stackoverflow.com/a/73027407/1167573 Upgrading the react-native project to the latest version of react-native should theoretically do the trick. Although, looking at the upgrade helper: https://react-native-community.github.io/upgrade-helper/?from=0.67.2&to=0.72.4 the required engine in package.json is still >=16 which doesn't ensure it's incompatible with node17 where the security fix took place.

@robhogan
Copy link
Contributor

robhogan commented Sep 4, 2023

the required engine in package.json is still >=16 which doesn't ensure it's incompatible with node17 where the security fix took place.

We changed Metro's hash function (md4->md5) in #752 (Metro 0.67+, React Native 0.68+) for compatibility with all supported Node versions without the need for flags.

If you're stuck on an old version, either using Node 16 or Node 17+ with --openssl-legacy-provider should work, but be aware that Xcode executes node in its own shell and may pick up a different version than your usual terminal. If it's using Node 17+, you'll need to set NODE_OPTIONS in Xcode as @pmella16 describes, which is equivalent to setting --openssl-legacy-provider by default in Xcode's node.

I'm going to close this because RN 0.67 is outside the support window and the root cause was fixed a while ago, but hopefully the above, and the context in #722, is helpful for folks on old versions.

@robhogan robhogan closed this as completed Sep 4, 2023
@flochtililoch
Copy link

flochtililoch commented Sep 27, 2023

For those still stuck on an older RN version, the Android equivalent to the suggested Xcode patch above is to configure the nodeExecutableAndArgs option of the react project settings in your gradle file, as such:

// android/app/build.gradle
project.ext.react = [
    nodeExecutableAndArgs: ["node", "--openssl-legacy-provider"],
]

@nguyenhoanglam
Copy link

For those still stuck on an older RN version, the Android equivalent to the suggested Xcode patch above is to configure the nodeExecutableAndArgs option of the react project settings in your gradle file, as such:

// android/app/build.gradle
project.ext.react = [
    nodeExecutableAndArgs: ["node", "--openssl-legacy-provider"],
]

works with v0.63.4. thanks mate!

@nakharinmsw
Copy link

I've used node version 16.18.0 run Metro yarn start --reset-cache. It work for me. 😃

@yeabsira-gashaw
Copy link

hi, try add this in target -> build phases -> bundle react native code and images

export NODE_OPTIONS=--openssl-legacy-provider

image

2 days of hassle is saved by your answer , Kudos !

@LoknathPraj
Copy link

export NODE_OPTIONS=--openssl-legacy-provider

i was trying to fix this issue from last 3-4 days.

Finally i fixed the issue with this solution. Thanks bro

@naveenkumar174
Copy link

naveenkumar174 commented Dec 13, 2023

export NODE_OPTIONS=--openssl-legacy-provider

i was trying to fix this issue from last 3-4 days.

Finally i fixed the issue with this solution. Thanks bro

How you fixed that?
I got the same issue on IOS build in bitrise
this is my script

#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x

export NODE_OPTIONS=--openssl-legacy-provider

# write your script here
find . -type l -exec test ! -e {} \; -delete

#.env update

replace_env_var () {
  sed -i '' "s~$1=.*~$1=$2~g" .env
}

replace_env_var "ENV_DISPLAY_NAME" "v$EURECAB_EM_VERSION"
replace_env_var "API_USER_AGENT" "Eurecab/$EURECAB_EM_VERSION"
replace_env_var "BACKEND_HOST" "$EM_PROD_BACKEND_HOST"
replace_env_var "API_VERSION" "$EM_PROD_API_VERSION"
replace_env_var "ADYEN_ENV" "$EM_PROD_ADYEN_ENV"
replace_env_var "ADYEN_CLIENT_KEY" "$EM_PROD_ADYEN_CLIENT_KEY"
replace_env_var "ADYEN_ENCRYPTION_PUBLIC_KEY" "$EM_PROD_ADYEN_ENCRYPTION_PUBLIC_KEY"
replace_env_var "FIREBASE_PRODUCTION_PROJECT" "true"
replace_env_var "BACKEND_HOST_EDITABLE" "false"
replace_env_var "RECAPCTHA_DOMAIN" "$RECAPCTHA_DOMAIN_PROD"
replace_env_var "RECAPTCHA_KEY" "$RECAPTCHA_KEY_PROD"

@LoknathPraj
Copy link

add this in target -> build phases -> bundle react native code and images

Add the below line in the script:
export NODE_OPTIONS=--openssl-legacy-provider

image

@naveenkumar174
Copy link

add this in target -> build phases -> bundle react native code and images

Add the below line in the script: export NODE_OPTIONS=--openssl-legacy-provider

image

Thank you very much for the help, now its working fine ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests