As easy as Node.js to learn and use, it can be problematic at times, especially when dealing with algorithms and key size. The occasional bug and glitch out of the blue is nothing new for seasoned developers but the error codes can be rather confusing at times.
In this article, we’re talking about the Error:03000086:digital envelope routines::initialization error, its causes and what can you do to fix the problem.
What causes the Error:03000086:digital envelope routines::initialization error?
The error is often triggered when using an incorrect encryption algorithm. However, other common factors include:
- Using an unsupported padding method.
- Unsupported key size.
- Using a missing or incorrect cryptographic key.
Also read: Error obtaining VCS status: Exit status 128: Quick Fix
How to fix Error:03000086:digital envelope routines::initialization error?
Here are three fixes you can try out.
Use legacy OpenSSL
The first and probably the easiest fix to the problem is to enable the openssl-legacy-provider flag to enable legacy algorithms and key sizes. To do so, use the flag in the start NPM script as follows.
NODE_OPTIONS=--openssl-legacy-provider npm run start
If you’re on Windows, use this instead.
set NODE_OPTIONS=--openssl-legacy-provider && npm run start
Finally, if you’re using React, update the start and build scripts in the package.json file.
"start": "react-scripts --openssl-legacy-provider start", "build": "react-scripts --openssl-legacy-provider build"
If updating packages didn’t work, a Webpack update might also be in order. First up, run the following command to check your existing Webpack version.
If the version is 4 or below, we need to update Webpack by running the following command
npm install [email protected]
Note that we’re using Webpack version 5.61.1. You can change this to whatever version is the latest at the time of the update.
Finally, updating Node.js itself can also resolve the issue. To do so, simply download and install the latest Node.js LTS version from the official website and you should be good to go.
Also read: How to fix error in ./src/reportWebVitals.js: Can’t resolve ‘web-vitals’?