npm run start crashes with ERR_OSSL_EVP_UNSUPPORTED after a Node.js upgrade
ERR_OSSL_EVP_UNSUPPORTEDShort answer
Node.js 17 and newer ship OpenSSL 3, which refuses some old algorithms and key sizes by default. An older build tool or dependency asks for one, so the process dies with ERR_OSSL_EVP_UNSUPPORTED. The quick fix is the --openssl-legacy-provider option. The lasting fix is to upgrade the tool, or to change the hash webpack uses.
Fix it fast
1Find out which cause you have
Print the Node.js version and find out which webpack version the project resolves. Node.js 17 or newer plus an old webpack points at the causes below.
node -v npm ls webpack2Match what you see, then jump to its fix
- 1
The crash started right after moving from Node.js 16 (or older) to 17 or newer, with no change to the project.A dependency uses an algorithm that OpenSSL 3 blocks by defaultFix - 2
npm ls webpack shows a version below 5.54 (webpack 4 inside react-scripts 4 or an old Vue CLI is typical).webpack hashes with md4, its default hash functionFix
- 1
What does the error look like?
ERR_OSSL_EVP_UNSUPPORTEDcode: 'ERR_OSSL_EVP_UNSUPPORTED'
Cause 1 of 2
A dependency uses an algorithm that OpenSSL 3 blocks by default
1Check
The Node.js 17 release notes say the error appears when an application or module uses an algorithm or key size that OpenSSL 3.0 no longer allows by default. Run the same command on an older Node.js to see if the error disappears.
node -v
node --openssl-legacy-provider -e "console.log('legacy provider accepted')"2Fix
As a temporary workaround, switch Node.js back to the legacy provider with --openssl-legacy-provider. The option is on the list of flags that NODE_OPTIONS accepts, so it can be set for npm scripts without editing them. Plan to upgrade the offending tool, since the Node.js notes call this flag temporary.
# macOS / Linux
export NODE_OPTIONS=--openssl-legacy-provider
npm run start
# Windows PowerShell
$env:NODE_OPTIONS = "--openssl-legacy-provider"
npm run start3Verify
The dev server or build starts without the error.
npm run startConfirmed by nodejs.org
Cause 2 of 2
webpack hashes with md4, its default hash function
1Check
The webpack documentation lists md4 as the default value of output.hashFunction. Find the config that sets, or fails to set, it.
npm ls webpack
grep -rn "hashFunction" webpack.config.js2Fix
Upgrade webpack, or the framework that bundles it, to a release that supports xxhash64, which webpack added in 5.54.0. If you own the webpack config, set the hash function explicitly.
// webpack.config.js (webpack 5.54 or newer)
module.exports = {
output: {
hashFunction: 'xxhash64',
},
};3Verify
A clean build finishes without --openssl-legacy-provider set.
unset NODE_OPTIONS
npm run buildConfirmed by webpack.js.org
How do I stop it coming back?
- Pin the Node.js version in the repo (an .nvmrc or the engines field) so a new laptop does not jump versions silently.
- Upgrade the bundler when you upgrade Node.js, not months later.
- Treat NODE_OPTIONS=--openssl-legacy-provider as a temporary patch and write down the upgrade it is waiting for.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fixBack end
The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1
Exit code 1 only says the build failed; the real message is above it.
2 causes, each with a fix