Post

React: fix digital envelope routines::unsupported

The “digital envelope routines::unsupported” error is a common issue that can occur in React.js projects when using outdated versions of Node.js or SSL packages. This error can be resolved by updating your Node.js version and SSL packages to the latest versions with security fixes.

Error Message

Starting the development server...

/Users/username/Documents/workspace/react-project/client/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/Users/username/Documents/workspace/react-project/client/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/username/Documents/workspace/react-project/client/node_modules/webpack/lib/NormalModule.js:417:16)
    at /Users/username/Documents/workspace/react-project/client/node_modules/webpack/lib/NormalModule.js:452:10
    at /Users/username/Documents/workspace/react-project/client/node_modules/webpack/lib/NormalModule.js:323:13
    at /Users/username/Documents/workspace/react-project/client/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /Users/username/Documents/workspace/react-project/client/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/Users/username/Documents/workspace/react-project/client/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /Users/username/Documents/workspace/react-project/client/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 v18.8.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Solution

If you encounter the “digital envelope routines::unsupported” error, you may be tempting to use the following easiest solutions:

  • Downgrade Node.js to pre v17 or;
  • Use the legacy SSL provider:

    1
    2
    3
    4
    5
    
    {
      "scripts": {
        "start": "react-scripts --openssl-legacy-provider start"
      }
    }
    

These solutions are considered hacks that leave your builds open to security threats. Downgrading Node.js or using the legacy SSL provider may temporarily resolve the issue, but they are not permanent solutions and can potentially introduce security vulnerabilities into your project.

The safest solution is to update both your Node.js version and SSL packages to the latest versions with security fixes. One way to do this is to use the following command:

1
npm audit fix --force

However, be aware that this command may not be suitable for complex builds, as it may pull in breaking security fixes that could potentially break your build.

If you use Yarn instead of NPM, the above solution may not work for you. In that case, you will need to find a similar solution specific to Yarn.

Reference

This post is licensed under CC BY 4.0 by the author.