Error message "error:0308010C:digital envelope routines::unsupported"
Olivia Zamora
I created the default IntelliJ IDEA React project and got this:
Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:67:19) at Object.createHash (node:crypto:130:10) at module.exports (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/util/createHash.js:135:53) at NormalModule._initBuildHash (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:417:16) at handleParseError (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:471:10) at /Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:503:5 at /Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:358:12 at /Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:373:3 at iterateNormalLoaders (/Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:214:10) at iterateNormalLoaders (/Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
/Users/user/Programming Documents/WebServer/untitled/node_modules/react-scripts/scripts/start.js:19 throw err; ^It seems to be a recent issue - webpack ran into this 4 days ago and is still working on it.
830 Answers
Here is two option now -
1. Try to uninstall Node.js version 17+ and reinstall the Node.js version 16+
You can re install the current LTS node js version from their official site. or more specific downloads from here;
You can use NVM (Node Version Manager)
- Linux and Mac users can use this nvm package -
- Windows users can use this nvm package -
2. Open terminal and paste these as described :
Linux & Mac OS (windows git bash)-
export NODE_OPTIONS=--openssl-legacy-providerWindows command prompt-
set NODE_OPTIONS=--openssl-legacy-providerReference link.
20In your package.json: change this line
"start": "react-scripts start"to
"start": "react-scripts --openssl-legacy-provider start" 8 If we use the current LTS version of Node.js then this error will not come. Downgrade your Node.js version to the current LTS version (16.13.0).
There can be multiple ways to install the required version. One of them is using nvm (Node.js version manager).
Step 1: Install nvm (if not installed, follow Install Node.js Locally with Node Version Manager (nvm))
Step 2:
nvm install 16.13.0(or lts)
It's the Node.js version.
I have this error on Node.js 17, but it's fine when I switch my Node.js version to an older version (16) by using nvm.
Some top answers did not work.
export NODE_OPTIONS=--openssl-legacy-providerAnd some top answers were not applicable, modifying package.json file:
"start": "react-scripts --openssl-legacy-provider start"This is caused by the latest node.js V17 compatible issues with OpenSSL, see this and this issue on GitHub.
The easiest thing is just downgrade from node.js V17 to node.js V16. See this post on how to downgrade node.js.
I found the commands below on GitHub:
For Windows, use the below command in cmd:
set NODE_OPTIONS=--openssl-legacy-providerFor Unix, use:
export NODE_OPTIONS=--openssl-legacy-provider 5 Failed to construct transformer: Error: error:0308010C:digital envelope routines::unsupported
The simplest and easiest solution to solve the above error is to downgrade Node.js to v14.18.1. And then just delete folder node_modules and try to rebuild your project and your error must be solved.
This worked for me (downgrading from Node.js 17 to Node.js 16):
nvm install --lts
nvm use --ltsUsing Node.js Version Manager (for Windows).
2This solution worked for me.
This error is coming in Node.js version 17+, so try to downgrade the Node.js version.
- Uninstall Node.js from the computer.
- Download Node.js version 16 and install it again from
That's all.
4check
node -v
v17.4.0then roll back to node --lts (node v16.13.2 (npm v8.1.2)) for that use nvm
for bash shell
curl -o- | bashfor zsh shell
curl -o- | zshafter nvm install
nvm install --ltscheck
node -v v16.13.2
retry again
2I faced this issue in Docker build, and I have added this line in the Docker file:
RUN export NODE_OPTIONS=--openssl-legacy-provider && yarn build && yarn install --production --ignore-scripts --prefer-offlineFor local development, add the switch in file package.json.
3If you are facing this error and you do not want to change your main configuration, an easy fix would be to use the following approach. I am not sure if it is recommended as a good practice, though.
Feel free to correct it.
Initially, let’s say this is the scripts section of my package.json file:
...
"version": "1.0.0", "scripts": { ... "build": "npm run build:test-app:testing", "build:test-app:testing": "ng build test-app --deploy-url --configuration=test-config", ... }, "private": true,
...In order to use this export NODE_OPTIONS=--openssl-legacy-provider you can do the following:
"version": "1.0.0", "scripts": {
.... "build": "NODE_OPTIONS=--openssl-legacy-provider npm run build:test-app:testing”, "build:test-app:testing": "NODE_OPTIONS=--openssl-legacy-provider ng build test-app --deploy-url --configuration=test-config"
... }, "private": true,Take note of the build scripts. I have added an option: NODE_OPTIONS=--openssl-legacy-provider
This helps solve this error in Node.js version 17.
For those with the flexibility of changing the build system's Node.js version, just switch to a version lower that 17, e.g., version 16.
For Docker, the use case of using this initially, which always pulls the latest version:
...
FROM node:alpine
...You can switch to something like:
...
FROM node:16-alpine3.12
... 0 This worked for me in my app expo (downgrading from Node.js 17 to Node.js 12 or 14).
If you have nvm installed you can change the version of node:
First check versions of Node.js in nvm:
nvm listSecond, install version 12 or 14:
nvm install v12.22.8 Reason:
This error is because node.js 17 uses OpenSSL3, which has changed code for initialization context of md family (including md4), and this is a breaking change. The error can also occur if you build the application using docker build since it pulls the latest version of Node.JS by default.
Install nvm Node Version Manager:
curl -o- | bashInstall latest LTS version:
nvm install --ltsUse LTS version:
nvm use --ltsDone!
Source:
0If you're using react-scripts you can now simply upgrade to version 5.0.0 (or above) which seems to have addressed this issue (it includes a newer version of webpack).
Running audit fixed the problem for me
npm audit fix --force 0 Same Error with node version v18.0.0and nuxt framework version 2.15 when running dev server and will be fixed by:
"scripts": { "dev": "NODE_OPTIONS=--openssl-legacy-provider nuxt"
} I was facing the same issue with Node.js 17.0.1. I solved it by following these steps:
Open Control Panel → Program and Features → Node.js and uninstall Node.js by right-clicking a
Go to website and download the version and install.
Go to::
And download the recommended version for most users.
Then uninstall Node.js from your PC and install the recommended version.
From what I understand, this is a problem from the developer team. They will fix it ASAP, but in the meantime use the recommended version and everything is going to be OK.
2If you are getting this error while using GatsbyJs, all you need to do is downgrade the node version to long-term support. There is no other salvation
Had this issue when using VueJS.
A disadvantage of using -openssl-legacy-provider is that it is not supported by older Node versions. Older Node versions simply don't run when this flag is provided.
But I still want to be compatible with Node v16 and older.
VueJS uses the md4 algorithm to generate hashes (wel actually it's WebPack under the hood). md4 can be easily replaced by md5 for these kind of purposes. The type of algorithm used, is on most places hard coded, so there's no way to configure another algorithm.
So I came up with another workaround. A function that intercepts the original createHash() call from the crypto module and replaces it with a modified version. This is at the start of my vue.config.js file:
const crypto = require('crypto');
/** * md4 algorithm is not available anymore in NodeJS 17+ (because of lib SSL 3). * In that case, silently replace md4 by md5 algorithm. */
try { crypto.createHash('md4');
} catch (e) { console.warn('Crypto "md4" is not supported anymore by this Node version'); const origCreateHash = crypto.createHash; crypto.createHash = (alg, opts) => { return origCreateHash(alg === 'md4' ? 'md5' : alg, opts); };
} Try:
npm create react-app --template typescript foo --use-npm 1 On Dockerfile you should add:
ENV NODE_OPTIONS=--openssl-legacy-provider 2 I have come across this issue today and have resolved it by switching Node.js version using "nvm".
I've been working on a couple of personal projects using Node.js, Next.js, and React... What often happens to me is that I don't remember exactly which version of Node.js do I use for which project.
And so usually I would try to use Node.js 16 for a project that is currently using Node.js 14 (I'm currently on Node.js 17).
I haven't figured out a better way to remember the version of Node.js for each project, so I usually would just save all commands that I need to run to get the application started in readme.MD.
In Angular.io projects, the accepted (unsupported) version of Nodes.js is v16.x.x.
In Nodes v17.x version, the same error described in this question occurs.
Solution:
Uninstall nodes and reinstall version v16.x (for Windows).
1You need to update react-scripts to the latest version
npm update react-scripts --save 1 This might not be an answer to the question for everyone. But for anyone running node 17 and above in docker, downgrading just as everyone has said will be helpful. No need for the open-legacy-sslprovider. A simple switch in your Dockerfile from using
From nodeto using
From node:16.* fixes this issue in docker.
1For Angular app: You can also edit the 'npm start' script in package.json instead
"start": "ng serve -o"
to
"start": "set NODE_OPTIONS=--openssl-legacy-provider && ng serve -o"
So every time when you run in terminal/command linenpm startit will first set the NODE_OPTIONS to avoid the problem.
In a terminal (OS X), simply downgrade like so:
sudo n 16.13.0 fixed by using lts
echo "lts" > .nvmrc
nvm install 2