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
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.
- Use the NVM to install Node.js.
- 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
Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.
I basically had to change `nvm alias default` to an earlier version of node (that worked with my current node_modules build)