Web development has come a long way from basic HTML and CSS pages and PHP backends. These days we have a lot of web development frameworks to work with and quickly deploy web apps and sites.
That said, it’s also gotten a lot more complex than simple HTML websites. In this article, we’re looking at the “Error: error:0308010c:digital envelope routines::unsupported” error, its reasons and what you can do to fix the problem.
What causes this error?
The error is caused when trying to run a React project on Nodejs version 17 or above. The error can also trigger if you’re building the project using Docker, as it pulls the latest available version of Node.js by default.
The problem here is Node.js 17’s push to use OpenSSL 3, changing the code required for the initialisation context of the md family.
How to fix this?
Here are two fixes you can try out.
Enable legacy OpenSSL support
You can circumvent the error by enabling support for legacy OpenSSL versions. There are two ways to do this using either the terminal or changing the package.json file.
Using the terminal
Use this command if you’re on macOS, Linux, or Windows Git Bash.
If you’re on Windows, use this command instead.
Using the package.json file (recommended)
You can also change the package.json file to let React know that you’re supporting legacy OpenSSL features. Just head over to the file and locate this line.
"start": "react-scripts start"
Change this to
"start": "react-scripts --openssl-legacy-provider start"
By downgrading the Node.js version
Another way to quickly get around the problem is by downgrading to the latest stable release version of Node.js (16.15.1 at the time of writing). Just open a terminal, and run the following command.
nvm install 16.15.1
Now try running the project, and it should build without any errors. Try forcing the LTS version using this command if you’re still getting the error.
nvm use --lts
Someone who writes/edits/shoots/hosts all things tech and when he’s not, streams himself racing virtual cars. You can reach out to Yadullah at [email protected], or follow him on Instagram or Twitter.