Openssl has removed support from insecure protocols. But some of the packages in nodejs are still using them. Due to this they are throwing 0308010C:digital envelope routines::unsupported error. In this article we will quickly look at various ways in which we can resolve this issue.
Solutions
- Downgrading NodeJS to version 16+
- Adding NODE_OPTIONS=–openssl-legacy-provider
- Running scripts with openssl-legacy-provider flag
- Updating versions of all packages
Downgrading Nodejs to version 16+
This issue arose in nodejs version 17+ so downgrading a version below will help. Use LTS version. You can download from here – https://nodejs.org/en/download/releases/
You can use nvm too –
nvm use 16
Or you can use the latest LTS version using this command –
# Linux / Mac nvm install --lts nvm use --lts # Windows nvm install lts nvm use lts
If you don’t have nvm then you can download it using this command –
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Add openssl-legacy-provider node option
You can enable the legacy methods of openssl using this command –
export NODE_OPTIONS=--openssl-legacy-provider
For windows cmd –
set NODE_OPTIONS=--openssl-legacy-provider
Running scripts with openssl-legacy-provider flag
You can run yours scripts with openssl-legacy-provider
flag by adding it into package.json
in start property. Like this –
"start": "react-scripts --openssl-legacy-provider start"
Updating versions of all packages
Another good solution is to keep all the packages updated by running an audit using this command –
npm audit fix --force
Solution for Nuxt Website
If you faced this problem in your nuxt website then update your script property in package.json with this –
"scripts": { "dev": "NODE_OPTIONS=--openssl-legacy-provider nuxt" }
Conclusion
In this article we saw multiple solutions to resolve 0308010C:digital envelope routines::unsupported error. According to your use case you may pick a solution and apply.