Fix - error:0308010C:digital envelope routines::unsupported


Borislav Hadzhiev

Last updated: Aug 23, 2022


Photo from Unsplash

Fix - error:0308010C:digital envelope routines::unsupported #

To solve the "error:0308010C:digital envelope routines::unsupported", set the NODE_OPTIONS environment variable to --openssl-legacy-provider when running your development server, or change your Node.js version to the LTS by issuing the nvm install --lts command.

error digital envelope routies unsupported

The first thing you should try is set the NODE_OPTIONS environment variable to --openssl-legacy-provider.

Open your terminal and run the following command:

# 👇️ macOS, Linux or Windows Git Bash export NODE_OPTIONS=--openssl-legacy-provider # ---------------------------------------------------- # 👇️ Windows CMD set NODE_OPTIONS=--openssl-legacy-provider

Alternatively, you can add the --openssl-legacy-provider flag when issuing the command in your package.json file.

Here is an example of how you would do that with create-react-app.

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

If that doesn't help, try to set the NODE_OPTIONS environment variable right before issuing the command.

Make sure to update the command after the environment variable depending on your use case.
{ "scripts": { "dev": "NODE_OPTIONS=--openssl-legacy-provider next dev", "build": "NODE_OPTIONS=--openssl-legacy-provider next build && next export", } }

If you run the command on Windows, you might get an error - "'NODE_OPTIONS' is not recognized as an internal or external command".

Install the cross-env package to solve the error.

npm install cross-env

And prefix the environment variable and the command with cross-env.

{ "scripts": { "dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider next dev", "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider next build && next export", } }

We simply prefixed the command in the package.json script with NODE_OPTIONS=--openssl-legacy-provider, e.g. NODE_OPTIONS=--openssl-legacy-provider YOUR_COMMAND_HERE.

If that didn't resolve your issue, run the node -v command and make sure you are running the long-term supported version of Node.js.

You can issue the following command if you use nvm:

nvm install --lts
The command will install and switch to the long-term supported version, which should resolve the issue.

The error often occurs when installing the latest version of Node. Rolling back to the long-term supported version solves it.

The --openssl-legacy-provider option is needed when using the latest version of Node.js, because Node.js 17 and later uses OpenSSL 3.0 which has had some breaking changes.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.