[Fixed] Error:0308010c:digital envelope routines::unsupported

To resolve the error "error:0308010C:digital envelope routines::unsupported" you can set the NODE_OPTIONS environment variable to --openssl-legacy-provider. To set the environment variable, use the following commands depending on your shell type:

Resolving - error:0308010c:digital envelope routines::unsupported

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:

$env:NODE_OPTIONS="--openssl-legacy-provider"

For Docker, include the following in your Dockerfile:

ENV NODE_OPTIONS="--openssl-legacy-provider"

You can also include the --openssl-legacy-provider flag in your package.json file in the scripts field. For example:

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

If you get an error that "node: --openssl-legacy-provider is not allowed in NODE_OPTIONS," unset the NODE_OPTIONS environment variable and rerun the command. On macOS, Linux or Windows Git Bash, use the following command:

unset NODE_OPTIONS

On Windows CMD (Command Prompt):

set NODE_OPTIONS=

On Windows PowerShell:

[Environment]::SetEnvironmentVariable('NODE_OPTIONS', '', 'User')
[Environment]::SetEnvironmentVariable('NODE_OPTIONS', '', 'Machine')

You can also set the NODE_OPTIONS environment variable right before issuing the command in your package.json file. For example:

{
  "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 may get an error saying "'NODE_OPTIONS' is not recognized as an internal or external command." To resolve this error, you can install the cross-env package and prefix the environment variable and the command with cross-env.

For example:

npm install cross-env

And in your package.json file:

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

FAQs

What is the "Error:0308010c:digital envelope routines::unsupported" error?

This error message typically occurs in cryptography and refers to an unsupported algorithm or operation that the digital envelope routines in OpenSSL were unable to process.

What causes the "Error:0308010c:digital envelope routines::unsupported" error?

This error can be caused by a number of factors, including outdated encryption algorithms, improper configuration of SSL/TLS certificates, or compatibility issues between different software systems.

How can the "Error:0308010c:digital envelope routines::unsupported" error be resolved?

The solution to this error will depend on the specific cause, but common fixes include updating encryption algorithms, configuring SSL/TLS certificates correctly, or identifying and addressing compatibility issues between systems. It may also be necessary to consult technical support or a qualified security expert for assistance.

Related: