Troubleshoot ERR_OSSL_EVP_UNSUPPORTED Error

13 Jul 20261 minute to read

When running your React application with the PDF Viewer, you may encounter the ERR_OSSL_EVP_UNSUPPORTED error. This error is related to OpenSSL, which is a cryptographic library used by Node.js for secure communication and encryption tasks. This specific error typically occurs when Node.js is trying to use cryptographic algorithms or routines that are not supported by the current version of OpenSSL being used.

Solution

To resolve this issue, run the following command in the same terminal session in which you plan to start your application, then start the app from that same session:

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

After setting the environment variable, start your application in the same terminal:

npm run dev

Permanent Solution

To avoid running this command every time, you can add it to your package.json scripts:

{
  "scripts": {
    "dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vite",
    "build": "SET NODE_OPTIONS=--openssl-legacy-provider && vite build"
  }
}

NOTE

For Mac/Linux, use export NODE_OPTIONS=--openssl-legacy-provider && instead of SET NODE_OPTIONS=--openssl-legacy-provider && in the scripts.