Goglides Dev 🌱

Goglides Dev 🌱 is a community of amazing users

Shaping the future of IT, one connection at a time.

Create account Log in
Balkrishna Pandey
Balkrishna Pandey

Posted on

Fix the Unsupported Digital Envelope Routines Error in MERN Stack

While learning the MERN stack, I came across a strange issue while following an official blog post and its accompanying GitHub repository. To start the web server, as suggested in the repository, I executed the following commands:

cd mern/client
npm install
npm start
Enter fullscreen mode Exit fullscreen mode

However, I encountered the following error message:

Starting the development server...

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/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
/Users/bpandey/Desktop/mern/mern-stack-example/mern/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/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/NormalModule.js:417:16)
    at /Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/NormalModule.js:452:10
    at /Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/webpack/lib/NormalModule.js:323:13
    at /Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/Users/bpandey/Desktop/mern/mern-stack-example/mern/client/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /Users/bpandey/Desktop/mern/mern-stack-example/mern/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.15.0
Enter fullscreen mode Exit fullscreen mode

After conducting some research, I discovered that the error message I encountered indicates a problem with the OpenSSL library, particularly with the use of unsupported digital envelope routines. This problem can arise when the OpenSSL version being used is incompatible with the version of Node.js installed on your system.

To resolve this issue, you can try either of the following solutions:

  • Update the OpenSSL library on your system to a more recent version.
  • Downgrade the version of Node.js to a version that is compatible with the OpenSSL version you are using.
  • Attempt to run npm install again to see if that resolves the issue.

In addition to the above suggested solutions, I came across another approach that resolved the issue for me. I added a script to my package.json file as follows:

"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
}
Enter fullscreen mode Exit fullscreen mode

Discussion (0)