
How to Fix Node.js Error 0308010C: digital envelope routines::unsupported
Quick fix: this error appears when you run Node.js 17 or later on a project (usually older webpack 4 or React Scripts 4) that relies on an algorithm OpenSSL 3 no longer enables by default. The permanent fix is to upgrade webpack or react-scripts. The fastest workaround is to set NODE_OPTIONS=--openssl-legacy-provider before running your command.
The error message
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:...)
at Object.createHash (node:crypto:...)
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
Why it happens
Node.js 17 upgraded from OpenSSL 1.1.1 to OpenSSL 3. OpenSSL 3 moved several older algorithms, including MD4, into a "legacy" provider that is not loaded by default. Webpack 4 used MD4 to create file hashes. When Node calls crypto.createHash("md4") on OpenSSL 3, it fails with ERR_OSSL_EVP_UNSUPPORTED. The same error can appear in any tool that uses an unsupported hash or cipher.
Fix 1: upgrade the dependency (recommended)
- Webpack: upgrade to webpack 5.54.0 or later, which no longer needs the unsupported hash.
- Create React App: upgrade
react-scriptsto version 5 or later. - Other tools: update the build tool that appears in the stack trace (Vue CLI, Angular CLI, Gatsby and others have fixed releases).
npm install react-scripts@latest
# or
npm install webpack@latest
Fix 2: use the OpenSSL legacy provider (quick workaround)
Set the Node option for the command you are running.
| Shell | Command |
|---|---|
| macOS / Linux | export NODE_OPTIONS=--openssl-legacy-provider |
| Windows Command Prompt | set NODE_OPTIONS=--openssl-legacy-provider |
| Windows PowerShell | $env:NODE_OPTIONS = "--openssl-legacy-provider" |
To apply it only to one script, put it in package.json. The cross-env package makes this work on every operating system:
"scripts": {
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider react-scripts start",
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider react-scripts build"
}
Note: the legacy provider turns older, weaker algorithms back on. Treat this as a temporary workaround and plan to upgrade. The flag also does not exist in Node 16 or earlier, so using it there causes a different error.
Fix 3: switch to Node 16
If you cannot upgrade the project right now, run it with Node 16, which uses OpenSSL 1.1.1. With nvm:
nvm install 16
nvm use 16
node -v
Add an .nvmrc file with 16 to your project so your team uses the same version. Node 16 is out of support, so use this only for legacy projects.
Which fix should you choose?
| Situation | Best fix |
|---|---|
| You own the project and can update packages | Upgrade webpack / react-scripts |
| You need it working right now | NODE_OPTIONS legacy provider |
| Old project you cannot touch | Use Node 16 with nvm |
| CI / Docker build fails | Set NODE_OPTIONS in the pipeline or use a matching Node image, then plan the upgrade |
Check that it is fixed
- Run
node -vto confirm which version is active. - Delete
node_modulesand the lock file only if upgrading, then runnpm install. - Run your start or build command again. The error should no longer appear.
FAQs
What does error 0308010C mean?
It is an OpenSSL error code. Together with "digital envelope routines::unsupported" it means the code tried to use an algorithm that OpenSSL 3 does not enable by default.
Does this affect Node 16 or 14?
No. It starts with Node 17, which includes OpenSSL 3. Node 18 and later behave the same way.
Is --openssl-legacy-provider safe?
It is fine for local development of an old project, but it re-enables weaker algorithms. Do not rely on it as a long-term production setting.
Why does it happen only on my new laptop?
You probably installed a newer Node.js there. Check with node -v and compare it with your old machine.
Related reading: Node.js environment variables and dotenv, understanding package.json, and the MD5 hash generator if you need to compute a hash yourself.
