If you’re a web developer, bugs and errors should be standard procedures for you. However, every once in a while we come across a bug that has a non-descript error message leaving us scratching our heads as to what needs to be done.
In this article, we’re talking about the Err_ossl_evp_unsupported issue, its causes and what you can do to fix the problem.
Also read: How to fix Javascript error: ipython is not defined?
What causes the Err_ossl_evp_unsupported error?
The error is generally triggered when your Node application or one of its modules attempts to use an algorithm or key size no longer supported by OpenSSL 3.0. While OpenSSL 3.0 APIs should be compatible with OpenSSL 1.1.1, there are issues with restrictions on allowed algorithms and key sizes and that’s why Node can throw this error out of the blue.
How to fix Err_ossl_evp_unsupported?
Here are four 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"
Update packages
The next step is to find out what packages are using these deprecated algorithms and update them to the latest version possible. It’s likely that the package that you’re using has been updated to be OpenSSL 3.0 compatible, meaning an update will likely fix the issue.
Update Webpack
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.
webpack --version
If the version is 4 or below, we need to update Webpack by running the following command
npm install webpack-cli@5.54.0
Note that we’re using Webpack version 5.54.0. You can change this to whatever version is the latest at the time of the update.
Update Node.js
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’?