How to Fix opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ]

Error:03000086:digital envelope routines::initialization typically occurs when there is a problem with initializing the digital envelope routines used in your Node.js application.

Overview of problem and solution

'error - 03000086 - digital envelope routines__initialization error'

How to fix the error:03000086:digital envelope routines::initialization

To fix the error:03000086:digital envelope routines::initialization, “uninstall Node.js version 17+ and reinstall Node.js version 16.”

Here is the step-by-step guide to fix the error.

Step 1: Install Node.js

There are many ways you can use to install Node.js in your application.

  1. Use the NVM to install Node.js.
  2. Install the current LTS Node.js version from their official site.

Step 2: Export OpenSSL Legacy Provider

For Linux and MacOS users, use the below command:

export NODE_OPTIONS=--openssl-legacy-provider

For Windows users, use the below command:

set NODE_OPTIONS=--openssl-legacy-provider

For Windows PowerShell users,

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

This will fix the error in your Node.js application.

In newer versions of Node.js, the default provider for OpenSSL has been changed, and this might not be backward compatible with certain older applications or libraries that depend on the legacy behavior of OpenSSL.

The –openssl-legacy-provider flag forces Node.js to use the legacy provider, which is why it resolves the issue.

Remember to include this environment variable setting in any startup scripts or deployment configurations to ensure it’s set whenever your application runs.

Using React.js

If you use a React application, add these scripts to the package.json file to resolve the error.

"scripts": {
   "start": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
   "build": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build"

Using Vue.js

If using a Vue.js application, add these scripts to the package.json file.

"scripts": {
   "serve": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
   "build": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
   "lint": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service lint"

In this code, –openssl-legacy-provider means you are most certainly running with known insecure SSL, so this might mitigate the symptom, but it presumably doesn’t fix the underlying problem.

If you are still facing the error, there might be a problem with encryption.

Related posts

error:0308010c:digital envelope routines::unsupported

1 thought on “How to Fix opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ]”

  1. I basically had to change `nvm alias default` to an earlier version of node (that worked with my current node_modules build)


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.