Node.js ERR_OSSL_EVP_UNSUPPORTED error: permanent solution and workaround option
Detect stale build dependency in Node.js OpenSSL error; Use webpack update, hash setting and legacy provider option in the right place.
When starting or compiling a project with Node.jsERR_OSSL_EVP_UNSUPPORTEDorerror:0308010C:digital envelope routines::unsupportedIf you see this, a cryptographic operation used may not be supported in the current OpenSSL configuration. A common cause of this in older Webpack-based projects is the old hash algorithm selection.
The permanent solution is to update the build tool or dependency that produces the error. The Legacy provider option should be considered as a temporary compatibility method. Before closing the error, find out which package started the process via stack trace.
1. Check Node and OpenSSL version
node --version
node -p "process.versions.openssl"
npm ls webpack react-scripts
Node.js 17 is one of the releases announcing the OpenSSL 3 migration. With this transition, the default algorithm constraints have changed. However, today it is not appropriate to install Node 17 as a solution or to permanently switch to Node 16 whose support period has expired. Choose a supported version of Node that is compatible with the project's tools.
Error in tracewebpack/lib/util/createHashIts appearance indicates hash production. Another package or application's owncryptoIf the call appears, look for the solution in that component. Don't accept every OpenSSL error as a Webpack error; Certificate and TLS issues require different scrutiny.
2. Update the package that manages the build tool
Plan compatible version upgrades and loader/plugin updates, if necessary, together in the project where you directly manage Webpack. webpackreact-scriptsIf it brings a framework or another CLI, first follow the migration path supported by that parent package. Adding arbitrary override to the child dependency may break the API the tool expects.
npm explain webpack
npm outdated
The goal here is not just to increase the version number, but to remove the component that requires the old algorithm. Save the selected versions together in the package.json and lock file. Then run the development server, production build, and tests of the project with the same Node version.
3. Hash selection directly in Webpack configuration
Using its own Webpack configuration andxxhash64The following setting can be considered for a project in a supported Webpack 5 version. In the Webpack documentation this option is mentioned for 5.54.0 and later:
// webpack.config.js - mevcut output ayarlarina ekleyin
module.exports = {
output: {
hashFunction: "xxhash64"
}
};
This part is not meant to replace your entire config file. Availableoutputadd it to the field. Some older loaders do their own hashing; The output setting may not change them. Intervene in the configuration hidden by the Framework only with the method it supports.
4. Temporary legacy provider option
If you urgently need to review an old project and the Node version you are using supports the option, you can try it only in the relevant terminal session. The PowerShell example preserves the existing NODE_OPTIONS value and restores it at the end of the transaction:
$previousNodeOptions = $env:NODE_OPTIONS
try {
$env:NODE_OPTIONS = "$previousNodeOptions --openssl-legacy-provider".Trim()
npm run build
} finally {
$env:NODE_OPTIONS = $previousNodeOptions
}
For single command in Linux or macOS terminal:
NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--openssl-legacy-provider" npm run build
This option opens access to legacy cryptographic algorithms; It does not update the dependency. Do not make permanent system-wide adjustments. If Node rejects the option, check the version and build properties; Don't assume that the same flag will work the same way on different machines.
What should you check if it's not working in CI?
On local and CIprocess.versionsCompare the output. Docker image, CI runtime setting and version manager may use different Node versions. Verify that the lock file has been committed and a clean installation has been performed. If the temporary flag is only present locally, the CI result will be different.
After permanent fix, recompile by removing legacy flag. A clean production build complete without a flag is a more valuable check to see if the old hash path is no longer in use.
Short guide
When to use?
If an old frontend or build project gives OpenSSL unsupported error after node upgrade.
Common mistake
Considering reverting to a non-supported Node version as a permanent solution or applying the legacy option to the entire system.