DEV Community

FOLASAYO SAMUEL OLAYEMI
FOLASAYO SAMUEL OLAYEMI

Posted on

How to Resolve Node.js ERR_OSSL_EVP_UNSUPPORTED Error

Are you facing the notorious ERR_OSSL_EVP_UNSUPPORTED error in your Node.js applications?
This error is a common stumbling block that occurs due to changes in cryptographic operations handling introduced with Node.js version 17. The root of the problem lies in the default configuration of OpenSSL in newer Node.js versions, which restricts the use of certain algorithms. Fortunately, there are effective solutions to overcome this error, ensuring your development process remains smooth and uninterrupted.

Why Does This Error Occur?

The ERR_OSSL_EVP_UNSUPPORTED error typically arises when applications or dependencies try to invoke cryptographic algorithms that are no longer supported by default in the OpenSSL version bundled with Node.js v17 and later. This change is part of an effort to enhance security by discouraging the use of older, potentially vulnerable cryptographic practices.

Resolving the Error

There are several strategies to resolve this error, each suited to different needs and project requirements. Below, we explore the most effective solutions:

1.Utilize the OpenSSL Legacy Provider

A quick fix to bypass this issue is to instruct Node.js to use the OpenSSL legacy provider. This can be achieved by setting an environment variable:

Temporary Fix:

export NODE_OPTIONS=--openssl-legacy-provider
npm start
Enter fullscreen mode Exit fullscreen mode

Permanent Fix:

Add the environment variable to your shell configuration file to ensure it persists across sessions.

echo 'export NODE_CODE=--openssl-legacy-provider' >> ~/.zshrc
source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

2.Downgrade Node.js

For projects that are not yet compatible with the latest Node.js versions, downgrading to an earlier version such as Node.js v16.x can be a practical solution:

Using nvm (Node Version Manager):

nvm install 16
nvm use 16
Enter fullscreen mode Exit fullscreen mode

If you don't have nvm installed, you can set it up easily:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

3.Update Your Dependencies

Keeping your project’s dependencies updated is crucial, especially those that utilize Node.js’s crypto APIs, such as webpack and sass-loader. An updated ecosystem can potentially resolve compatibility issues:

npm update
Enter fullscreen mode Exit fullscreen mode

Conclusion

Choosing the right approach to resolve the ERR_OSSL_EVP_UNSUPPORTED error depends on your project's specific needs and environment. Whether you opt for a quick workaround by setting an environment variable, downgrade Node.js for compatibility, or update your dependencies for a more long-term solution, each method offers a reliable way to keep your Node.js applications running smoothly.

Thanks for reading...
Happy Coding!

Top comments (0)