error:0308010C:digital envelope routines::unsupported

The error message error:0308010C:digital envelope routines::unsupported, appears to be related to OpenSSL. This error typically indicates that a particular feature or operation is not supported by the version of OpenSSL or the configuration being used. OpenSSL is a widely used cryptographic library that provides support for secure communications. When working on encryption and decryption tasks within Node.js, you may come encounter this specific type of error. Let’s understand the error and explore the solution to fix it.

Common Causes of the Error

There are several common reasons why you might encounter error:0308010C:digital envelope routines::unsupported error which includes OpenSSL version or its configuration, Node.js version, the functionality of algorithms which does not support the version of OpenSSL, Incomplete or incorrect installation of system libraries and dependencies, Incomplete or inaccurate verification of SSL/TLS Certificates and Keys and others.

How to fix “error:0308010C:digital envelope routines::unsupported”?

Here we have mentioned some approaches to fix the “error:0308010C:digital envelope routines::unsupported” error in Node.js. Go through all the approaches and follow the steps given below:

Downgrade the version of Node.js and nvm

You have to use the version of node.js 16 if you are using the other version then There is a possibility that the other version of node.js does not support the particular operation you are trying to perform. use the following command to downgrade the version of node.js.

nvm install 16
nvm use 16

Check the version of node.js using the below command:

node -v

Set the NODE_OPTIONS environment variable to –openssl-legacy-provider

To set the NODE_OPTIONS environment variable, open the terminal and type the following command:

# for macOS, Linux or Windows Git Bash
export NODE_OPTIONS=--openssl-legacy-provider

# for Windows CMD (Command Prompt)
set NODE_OPTIONS=--openssl-legacy-provider

# for Windows PowerShell

# for Docker (in your Dockerfile)
ENV NODE_OPTIONS="--openssl-legacy-provider"

Use –openssl-legacy-provider flag

If you are developing a React app, another solution for addressing the error involves appending the ‘–openssl-legacy-provider’ flag to the start script within the package.json file.

“scripts”: {
“start”: “react-scripts start –openssl-legacy-provider”,

Keep the NPM packages updated

If none of the previously mentioned solutions prove effective to resolve the error “error:0308010C:digital envelope routines::unsupported”, attempt to audit npm packages by using the below command.

npm audit fix –force