Due to a breaking change in Node.js version 17 error:0308010c:digital envelope routines::unsupported occur, which used OpenSSL form 3 by default.
Interface solutions like Webpack, create-react-app, or vue-cli-service, If you work with Node.js and the command line. You might have encountered the error:0308010c: digital envelope routines::unsupported. You’re not alone because more people are currently getting it too. The React app indeed failed to start.
You can fix the error:0308010C:digital in Node JS by setting the environment variable NODE_OPTIONS=–openssl-legacy-provider.
There are two main reasons for getting this error:
You’re not using the LTS (long-term support) version of Node JS. Some people use Node 17.0.0, which is not an LTS version of Node.
- You’re using react-script with a version of less than 5
- If you’re using Node 17, the error can also occur.
Outdated Software: It may not support the encryption method used in the digital envelope if the recipient’s device runs outdated software. It can result in an error message.
Incompatible Software: In some cases, the recipient’s device may be running software incompatible with the encryption method used in the digital envelope. It can result in an error message.
Corrupted Data: If the data in the digital envelope is corrupt, it may result in an error message. It can happen during transmission or due to the sender’s device malfunction.
Why this error occurs?
Command line tools like Webpack uses the “MD4 algorithm” to create file messes. These file messes are then used to record changes in your JavaScript files.
By default, OpenSSL version 3 didn’t enable the MD4 algorithm support. If you upgraded Node.js to version 17 and above, you’d see this error when building an application using Webpack.
Cause for The Error
You might be using Node.js version 17+. In Node.js version 17+, MD4 algorithms are migrated into OpenSSL 3.0’s legacy provider. Hence, this error will occur if you do not pass the –openssl-legacy-provider flag. The legacy provider is not loaded by default and can be added to the application as required.
If you’re working with react application, you might be using the react-script version less than 5.0.0
How to Fix the Error?
To fix this error, there are at least three ways. Any of them should work for you. So we are going to look at them one by one.
Pass –openssl-legacy-provider to Webpack or the CLI Tool
For instance, you can pass –openssl-legacy-provider to the start script like this “react-scripts –openssl-legacy-provider start” in a React app.
That should do it. On many occasions, it works. But if this step fails to fix the error, then continue to the next fix.
Use an LTS Version of Node JS
Consider decreasing your Node version to 16.16.0 or different LTS versions. Currently, the latest LTS version of Node is 18.12.1. From the Node JS official website, you can download it or install it using NVM.
Upgrade React Script to Version 5+
It still fails to fix the error for you working with React, which is likely an issue with your React script.
Upgrade your version to 5+, If you’re using a React script version of less than 5.
In my case, people presently via react-scripts 3.4.3:
You can do it in two ways to upgrade react-scripts to 5+
Here are some steps to Uninstall and reinstall react-scripts
- open the incurable and run npm uninstall react-scripts
- run npm fix react-scripts
Manually Change the react script version
- go to your package.json and change the react-script version to 5.0.2
- remove the node modules file by running rm –rf node modules
- delete the package.lock.json file by running rm –rf package.lock.json
- run npm install or yarn add, liable on the package manager you’re using
- After upgrading the version of react-scripts to 5+, your React app is now working fine
Reinstall the latest Node.JS version and reinstall versions lower than Node.JS 16; this is the easiest solution to fix this error from your program. For instance, older versions support webpack version 4, which works great when making complex Node.JS documents.
In addition, creators and programmers can install older Node.JS versions from their certified website, which is the best place to find a suitable program.
Conclusion
If you are facing the error, then it could happen you’re not using an LTS version of Node JS, or you’re via react-scripts version <5. We discussed some of the solutions to fix the error in this article, and I hope it will help you to fix this error. If any fixes work for you, you will go with the others. In my case, upgrading react-scripts to 5+ was what worked for me.
Review Error:0308010c:digital envelope routines::unsupported.