Getting “Error: error:0308010C:digital envelope routines::unsupported” or ERR_OSSL_EVP_UNSUPPORTED when you run ng serve, ng build or ionic serve? This guide explains why it happens on newer Node.js versions and shows 5 fixes, from a one-line workaround to the proper long-term solution.
You open an older Angular or Ionic project, run ng serve, ng build or ionic serve, and it fails straight away with this:
Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:69:19) at Object.createHash (node:crypto:133:10) at module.exports (node_modules/webpack/lib/util/createHash.js:135:53) ... opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED'
The file paths and line numbers differ on your machine, but the important parts are the same: digital envelope routines::unsupported, the code ERR_OSSL_EVP_UNSUPPORTED, and a webpack file in the stack trace.
Why Does This Error Happen?
Starting with Node.js 17, Node uses OpenSSL 3. OpenSSL 3 no longer allows some older hashing algorithms by default, including MD4. Webpack 4, the bundler used inside older Angular and Ionic projects, still asks for MD4 when it builds your app, so Node refuses and the build stops.
In other words, the combination newer Node.js + older webpack 4 causes the error. Your code is usually fine. You will most often see it:
- after installing a new Node.js version on a new laptop or in a new Docker image,
- when a CI service updates its default Node version,
- when you open an older project, typically Angular 11 or older, which uses webpack 4. Angular 12 switched to webpack 5.
Other tools built on webpack 4, such as Create React App 4 and Vue CLI 4, show the same error.
Step 1: Confirm the Cause
Check your Node.js version and which webpack version your project uses:
node -vnpm ls webpackng version
If Node is version 17 or higher and webpack is version 4.x, you have found the cause. If your project already uses webpack 5, the error comes from an old plugin or loader instead, so check the first line of the stack trace to see which package calls createHash.
Step 2: Quick Workaround With the Legacy OpenSSL Provider
This tells Node to allow the old algorithm again. Set it for your current terminal session before running the build.
macOS and Linux:
export NODE_OPTIONS=--openssl-legacy-providerng serve
Windows Command Prompt:
set NODE_OPTIONS=--openssl-legacy-providerng serve
Windows PowerShell:
$env:NODE_OPTIONS="--openssl-legacy-provider"ng serve
This is the fastest way to get an old project running, but it is a workaround, not a real fix. It only affects the terminal where you set it, so a new terminal window will show the error again.
Step 3: Put the Workaround in package.json
To avoid retyping it, add the setting to your npm scripts. The cross-env package makes the same line work on Windows, macOS and Linux:
npm install --save-dev cross-env
{ "scripts": { "start": "cross-env NODE_OPTIONS=--openssl-legacy-provider ng serve", "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider ng build" }}
Now npm start and npm run build work on any machine. For an Ionic project, use the same pattern with your existing script, for example ionic serve or ionic build.
Step 4: Use an Older Node.js Version for the Old Project
Instead of changing the project, you can run it on a Node version that still uses OpenSSL 1.1, such as Node 16. The easiest way is nvm, which lets you keep several versions side by side:
nvm install 16nvm use 16node -v
On Windows with nvm-windows, you may need to give a full version number, such as nvm install 16.20.2. To make the choice automatic for the project, create a file named .nvmrc in the project root:
16
Then anyone can run nvm use inside the folder. Keep in mind that Node 16 no longer receives security updates, so use it only for local work on legacy projects, not for servers exposed to the internet.
Step 5: The Proper Fix, Upgrade the Project
The real solution is to move to a version that uses webpack 5, so you no longer need any workaround. For Angular, upgrade one major version at a time and commit after each step:
ng update @angular/core@<next-major> @angular/cli@<next-major>
Replace <next-major> with the next major version number, and repeat until you reach a current version. After each step, update Ionic and your plugins to versions that support that Angular version. If npm stops with a dependency conflict during the upgrade, see my guide on fixing the npm ERESOLVE error.
Upgrading takes more time than the workarounds, but it also fixes slow builds, security warnings and many other problems that old toolchains bring.
Step 6: Fix CI, Docker and Hosting Builds
If the error appears only on your build server, the server probably moved to a newer default Node version. Pin the version instead of relying on the default.
GitHub Actions:
- uses: actions/setup-node@v4 with: node-version: 16
Docker (choose one of these two lines):
FROM node:16-alpine# or keep a newer Node image and add the workaround:ENV NODE_OPTIONS=--openssl-legacy-provider
On hosting platforms such as Vercel or Netlify, set the Node version in the project settings, or add an environment variable named NODE_OPTIONS with the value --openssl-legacy-provider.
Is the Legacy Provider Safe?
- For local development and build tools, it is a common and accepted workaround, because the old algorithm is only used to create file hashes during the build.
- Do not leave it enabled globally on production servers that handle network traffic, since it re-enables older cryptographic algorithms in the whole Node process.
- Treat it as temporary, and plan the upgrade in Step 5.
Which Fix Should You Choose?
| Situation | Best fix |
|---|---|
| You need the project running right now | Step 2: NODE_OPTIONS for this terminal |
| The whole team uses the old project | Step 3: scripts with cross-env |
| You do not want to touch the project | Step 4: Node 16 with nvm and .nvmrc |
| You want the problem gone for good | Step 5: upgrade Angular and Ionic |
| Only the build server fails | Step 6: pin the Node version or set the variable |
Best Practices to Avoid This Error
- Add a
.nvmrcfile and anenginesfield topackage.jsonso everyone uses the same Node version. - Pin the Node version in CI and Docker instead of using
latest. - Upgrade old Angular and Ionic projects regularly, rather than waiting for a forced jump of many versions.
- Document any
NODE_OPTIONSworkaround in your README so teammates know why it exists.
Conclusion
The ERR_OSSL_EVP_UNSUPPORTED error is a version mismatch, not a bug in your code. Newer Node.js versions block an old hashing algorithm that webpack 4 still uses. Use the --openssl-legacy-provider flag or Node 16 to get unblocked quickly, and plan the upgrade to webpack 5 so the problem disappears permanently.

0 Comments