Node.js 17.0.1 Gatsby error - "digital envelope routines::unsupported ... ERR_OSSL_EVP_UNSUPPORTED"
Solution 1:
This might help. Add these scripts in the package.json file.
React:
"scripts": {
"start": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
"build": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build"
}
or
"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
}
Vue.js:
"scripts": {
"serve": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
"lint": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service lint"
},
or
"scripts": {
"serve": "vue-cli-service --openssl-legacy-provider serve",
"build": "vue-cli-service --openssl-legacy-provider build",
"lint": "vue-cli-service --openssl-legacy-provider lint"
},
Solution 2:
Gatsby must be using an algorithm or key size which is no longer allowed by default with OpenSSL 3.0.
UPDATE ⚠️
This is most likely a webpack issue - https://github.com/webpack/webpack/issues/14532
They have since released a fix in version 5.61.0 - https://github.com/webpack/webpack/releases/tag/v5.61.0 - so upgrading webpack should address the issue as well
A member of the webpack team has stated they do not plan to backport the fix to webpack 4, so if you are on webpack 4 you may need to look to upgrading to webpack 5 first.
From Node.js 17's announcement post:
If you hit an
ERR_OSSL_EVP_UNSUPPORTED
error in your application with Node.js 17, it’s likely that your application or a module you’re using is attempting to use an algorithm or key size which is no longer allowed by default with OpenSSL 3.0. A new command-line option,--openssl-legacy-provider
, has been added to revert to the legacy provider as a temporary workaround for these tightened restrictions.
Running this on the terminal might look like:
node --openssl-legacy-provider ./node_modules/.bin/gatsby build
You can also pass this in via the NODE_OPTIONS environment variable.
So if you'd like to continue using the NPM script, you can change the build
script to:
// package.json
{
"scripts": {
"build": "export NODE_OPTIONS=--openssl-legacy-provider; gatsby build"
}
}
Solution 3:
Quick fix: Run this in a terminal inside your React project.
export NODE_OPTIONS=--openssl-legacy-provider
Solution 4:
I also had the same problem, so I just degraded the Node.js version:
-
Uninstall Node.js
-
Then download and install 16.13.0.