If you are using Node.Js, and any command line interface solution like WebPack, React Script, etc. you are most likely going to encounter the “error: error:0308010c:digital envelope routines::unsupported” error on Node.Js.
Node.Js developers have closed a security hole in the SSL provider. This fix is a breaking change that corresponds with similar breaking changes in the SSL packages in Nord Package Manage. If there is an attempt to use SSL in Node.js v17 or later without upgrading the SSL packages in your package.json, this error is inevitable.
Other causes of this error includes;
- You are not using the long term version(LTS) of Node.Js. Anything like Node 17.0.0, which is not an LTS version of Node.
- You are using a React Script with a version less than 5
How To Fix Error: error:0308010c:digital envelope routines::unsupported:
1. Openssl Legacy Provider
Pass –openssl-legacy-provider to WebPack or the CLI tool. In React Script , you can pass –openssl-legacy-provider to the start script like this:
--openssl-legacy-provider
Additionally, you can run the legacy openssl provider on Unix, eg Linux, MacOs, GitBash.
export NODE_OPTIONS = ----openssl-legacy-provider
On Windows, the command prompt will be:
set NODE_OPTIONS = ----openssl-legacy-provider
On Power Shell:
$env NODE_OPTIONS = ----openssl-legacy-provider
2. Use an LTS Version Of Node.Js
You can downgrade to Node version 16.16.0, or other possible LTS versions. As of now, 18.12.1 is the latest LTS version of Node.Js, simply download it from Node.Js official website . You can install through Node Version Manager (NVM) for Node.Js.
3. Upgrade React Script to a Version Higher than 5
If you work with React Scripts, and none of these hacks helped eliminate the error. The problem is likely from the React Script. If your React Script is less than version 5, then you need to upgrade to a version higher than 5. They are two ways to go about it:
4. Uninstall and Reinstall React Script
Run:
npm uninstall react script.
Then run:
npm install script
On the open terminal. This command uninstalls, and reinstalls React Script.
5. Do a Manual Change of the React Script Version
Go to package.json and change the React Script version to 5.0.2
Run
rm-rf package.lock.json
to delete the package.lock.json file.
Then run;
npm install.
This upgrade will help React Script work properly and avoid this error.
6. Reconfigure WebPack
If you are using WebPack, reconfigure to either of these;
WebPack v5
output.hashFunction='xxhash64'
WebPack v4
output.hashFunction=sha512
output.hashFunction=sha256
Any of these solutions will work fine and resolve the ‘error: error:0308010c:digital envelope routines::unsupported’ error on Node.Js.