How To Fix ERR_OSSL_EVP_UNSUPPORTED In React JS Application

You are using Node JS 17 and hitting this error during application start up using npm start command.

Error

The error ERR_OSSL_EVP_UNSUPPORTED has been mentioned in the release notes for Node.js 17.

If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application with Node.js 17, it’s likely that your application or a module you’re using is attempting to use an algorithm or key size which is no longer allowed by default with OpenSSL 3.0. A command-line option, --openssl-legacy-provider, has been added to revert to the legacy provider as a temporary workaround for these tightened restrictions.

ERR_OSSL_EVP_UNSUPPORTED

Probably your error stack trace would be like the following output:

spring-boot-react-crud-app\node_modules\react-scripts\scripts\start.js:19
  throw err;
  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (C:\React\spring-boot-react-crud-app\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (C:\React\spring-boot-react-crud-app\node_modules\webpack\lib\NormalModule.js:417:16)
    at C:\React\spring-boot-react-crud-app\node_modules\webpack\lib\NormalModule.js:452:10
    at C:\React\spring-boot-react-crud-app\node_modules\webpack\lib\NormalModule.js:323:13
    at C:\React\spring-boot-react-crud-app\node_modules\loader-runner\lib\LoaderRunner.js:367:11
    at C:\React\spring-boot-react-crud-app\node_modules\loader-runner\lib\LoaderRunner.js:233:18
    at context.callback (C:\React\spring-boot-react-crud-app\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at C:\React\spring-boot-react-crud-app\node_modules\babel-loader\lib\index.js:59:103 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v17.0.1

Solution

As a workaround solution you can fix this by using the legacy provider for openssl. So, you need to edit the package.json file under your application’s root directory and check for the following lines and replace them accordingly.

replace "start": "react-scripts start" by "start": "react-scripts --openssl-legacy-provider start"
replace "build": "react-scripts build" by "build": "react-scripts --openssl-legacy-provider build"

Your package.json file should look like the below image:

ERR_OSSL_EVP_UNSUPPORTED

Save the package.json file and execute the command npm start again on your application’s root directory using CLI.

Your application should start and open browser with URL http://localhost:3000.

Leave a Reply

Your email address will not be published. Required fields are marked *