Fix ERR_OSSL_EVP_UNSUPPORTED In React Native

Why is this error occurring?

The ERR_OSSL_EVP_UNSUPPORTED error in a React JS application typically arises due to an underlying issue with the version of Node.js and OpenSSL being used. This error is commonly encountered when certain cryptographic algorithms or keys are not supported by the OpenSSL version bundled with the Node.js installation.

How can I fix this error?

Node.js 17 has a new option called –openssl-legacy-provider. This option lets you go back to using the old way of doing things until you can update your code to work with the new rules.

package.json file

package.json
1
2
3
4
5
{
"scripts": {
"start": "node --openssl-legacy-provider index.js"
}
}

set environment variable

1
export NODE_OPTIONS=--openssl-legacy-provider

change it in the gradle file

build.gradle
1
2
3
project.ext.react = [
nodeExecutableAndArgs: ["node", "--openssl-legacy-provider"]
]

change it in the Xcode build settings

project.pbxproj
1
2
3
buildSettings = {
NODE_OPTIONS = "--openssl-legacy-provider";
}

After changes, try running the application again. Or you also need to reinstall the dependencies.