Introduction

Error: error:0308010C:digital envelope routines::unsupported. If you’re running Webpack or a CLI tool that relies on Webpack (for example, react scripts for Create React Apps or vue-cli-service for Vue apps) with Node.js version 17, you might have encountered the following above error:

How to fix error:0308010C:digital envelope routines::unsupported

How to fix error_0308010C_digital envelope routines__unsupported

The “error: 0308010C: digital envelope routines:: unsupported” occurs when you are using Node.js version 17+ and using OpenSSL v3.0, which has some significant changes to its algorithm.

The error can be fixed in the following ways.

  • Set the NODE_OPTIONS environment variable to –openssl-legacy-provider
  • Pass the –openssl-legacy-provider flag to Webpack
  • To build React app apps, update react scripts to v5.0.0 or higher
  • Downgrade the installed version of node.js to 16 or lower

1. To Fix This Bug, You Need to Upgrade to Webpack 5

The fix for this bug is released in Webpack 5.61.0, in which the maintainer sokra added an MD4 implementation via Web Assembly.

If you are using Webpack directly in your package.json file, you can update Webpack to version 5:

npm install webpack @ latest

Unfortunately, if your developer tool uses Webpack internally (like Create React App and vue-cli), then you can’t update Webpack version this way.

You must wait until the tool releases a new version that fixes this bug, or you can use one of the solutions below.

2. Add The –Openssl-Legacy-Provider Flag to Your Build Script

As a workaround, you can add the –OpenSSL-legacy-provider flag to the build script defined in package.json.

The Open SSL legacy provider is a collection of legacy algorithms that are no longer in everyday use, such as MD2, MD4, MDC2, etc.

You can add the flag to enable these legacy algorithms. Here are some examples of Create React and vue-cli applications:

// For React:
{
“scripts”: {
“start”:
} “react-scripts start –openssl-legacy-provider”
}

// For Vue:
{
“scripts”: {
“serve”: “vue-cli-service serve –openssl-legacy-provider”
},
}

If you see an error that says Error: Unknown argument: openssl-legacy-provider, you can set the NODE_OPTIONS environment variable before running the build command.

Depending on your terminal, run one of the following commands:

# macOS, Linux and Windows Git Bash
export NODE_OPTIONS=–openssl-legacy-provider

# Windows Command Prompt:
set NODE_OPTIONS=–openssl-legacy-provider

# Windows PowerShell:
$env:NODE_OPTIONS=”–openssl-legacy-provider”

Then run your build command, for example:

export NODE_OPTIONS=--openssl-legacy-provider
npm start

With the legacy provider enabled, the error should go away.

What causes the error “0308010c: digital envelope routines::unsupported”?

There could be many reasons for this error to occur, but below are the main 2 reasons that could the cause:

  • You may be using the wrong LTS (Long Term Support) version of NODE JS. Node 17.0.0 will fail because it is not an LTS version of Node.
  • If your react script version is less than 5, it will fail because it is not supported.