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.
Santiago Trujillo
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 list
Second, install version 12 or 14:
nvm install v12.22.8
In a terminal (OS X), simply downgrade like so:
sudo n 16.13.0
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).
fixed by using lts
echo "lts" > .nvmrc
nvm install
check
node -v
v17.4.0
then roll back to node --lts (node v16.13.2 (npm v8.1.2)) for that use nvm
for bash shell
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
for zsh shell
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | zsh
after nvm install
nvm install --lts
check
node -v
v16.13.2
retry again
If 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).
In your package.json file:
Change the line
"start": "react-scripts start"
to
"start": "react-scripts --openssl-legacy-provider start"
Some top answers did not work.
export NODE_OPTIONS=--openssl-legacy-provider
And 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 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.
Go to:: https://nodejs.org/en/
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.
This solution worked for me.
This error is coming in Node.js version 17+, so try to downgrade the Node.js version.
That's all.
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 https://nodejs.org/en/ and download the version and install.
This worked for me (downgrading from Node.js 17 to Node.js 16):
nvm install --lts
nvm use --lts
Using Node.js Version Manager (for Windows).
On Dockerfile you should add:
ENV NODE_OPTIONS=--openssl-legacy-provider
I found the commands below on GitHub:
For Windows, use the below command in cmd:
set NODE_OPTIONS=--openssl-legacy-provider
For Unix, use:
export NODE_OPTIONS=--openssl-legacy-provider
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
.
Try:
npm create react-app --template typescript foo --use-npm
If 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 https://test-app.com/ --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 https://test-app.com/ --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
...
I 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-offline
For local development, add the switch in file package.json.
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)
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.
Here is two option now -
1. Try to uninstall Node.js version 17+ and reinstall the Node.js version 16+
2. Open terminal and paste these as described :
Linux & Mac OS (windows git bash)-
export NODE_OPTIONS=--openssl-legacy-provider
Windows command prompt-
set NODE_OPTIONS=--openssl-legacy-provider
Reference link.
In your package.json: change this line
"start": "react-scripts start"
to
"start": "react-scripts --openssl-legacy-provider start"