Fixing error:0308010c:digital envelope routines::unsupported in Node.js

If you’re running a Node.js application and suddenly encounter this cryptic message —
error:0308010c:digital envelope routines::unsupported — don’t panic. You’re not alone. This error has become increasingly common, especially after upgrading to Node.js v17 or later. In this blog post, we’ll break down what causes this error, how to fix it, and how to prevent it in the future.

What Does error:0308010c:digital envelope routines::unsupported Mean?

This error stems from OpenSSL 3, which was introduced in Node.js 17.x. Some cryptographic functions that worked in earlier versions now require updated configurations. As a result, older tools like Webpack or certain npm packages throw this unsupported error.

Common Situations Where This Error Occurs

You may encounter this error when:

  • Running a React, Vue, or Angular project.
  • Starting a Webpack development server.
  • Running a Next.js or Create React App project.
  • Executing Node.js scripts using cryptography modules.

How to Fix error:0308010c:digital envelope routines::unsupported

Below are multiple ways to solve this issue, depending on your needs.

1. Use the Legacy OpenSSL Provider (Most Common Fix)

Add the following flag when running your Node.js application:

NODE_OPTIONS=--openssl-legacy-provider

For example:

NODE_OPTIONS=--openssl-legacy-provider npm start

Or, on Windows:

set NODE_OPTIONS=--openssl-legacy-provider && npm start

This tells Node to use legacy cryptographic behavior compatible with older dependencies.

2. Downgrade Node.js to v16

If you don’t need the features of Node.js 17+, simply downgrade to a stable LTS version like v16, which is more compatible with many existing packages.

Use nvm (Node Version Manager) to easily switch versions:

nvm install 16
nvm use 16

Then rerun your app.

3. Upgrade Your Dependencies

If you’re using Webpack, upgrade to version 5.61 or later. Many libraries have since fixed this issue with OpenSSL 3 compatibility.

Run:

npm update

Or manually update Webpack:

npm install webpack@latest

Check your package.json to ensure you’re using compatible versions of all dependencies.

4. Modify package.json Scripts

You can permanently apply the fix by modifying your package.json script like this:

"scripts": {
  "start": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start"
}

This avoids having to set the flag manually each time.

5. Set Environment Variable Globally

For a more permanent system-wide fix (advanced users only), you can set the NODE_OPTIONS variable globally on your machine.

Linux/macOS:

export NODE_OPTIONS=--openssl-legacy-provider

Windows (CMD):

setx NODE_OPTIONS "--openssl-legacy-provider"

Why This Happens: A Deeper Technical Explanation

Node.js 17+ uses OpenSSL 3, which disables some outdated algorithms by default. When libraries like Webpack rely on these older algorithms, they fail unless:

  • They are updated to support modern encryption, or
  • Node.js is told to use legacy OpenSSL behavior.

Pro Tip: Always Use LTS for Production

For stable development and deployment, always stick with a Long-Term Support (LTS) version of Node.js unless you specifically need newer features.

Final Thoughts

The error:0308010c:digital envelope routines::unsupported may look intimidating, but it has easy and reliable fixes. Whether you choose to add the legacy OpenSSL flag, downgrade Node.js, or upgrade your dependencies, you’re only a few steps away from resolving it.

Keywords :

  • error:0308010c:digital envelope routines::unsupported
  • Node.js OpenSSL 3 error
  • fix digital envelope routines unsupported
  • node openssl-legacy-provider
  • Webpack error Node.js 17
  • digital envelope routines error in React