474

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.

a1cd
  • 5,259
  • 2
  • 7
  • 26
  • 1
    Do the workarounds mentioned in that issue link work for you? – Mike 'Pomax' Kamermans Oct 23 '21 at 23:58
  • 1
    I got the same error from using next js I downgraded my node version and now that error won't show up. – migara Oct 24 '21 at 05:16
  • @Mike'Pomax'Kamermans There are no workarounds in the issue by Webpack :/ This is why I asked this question. – a1cd Oct 25 '21 at 20:19
  • 2
    Yes there are? https://github.com/webpack/webpack/issues/14532#issuecomment-947012063 was posted 6 days ago (and there's lots of followup since then from people asking exactly how to use that, with lots of explanations by several folks). – Mike 'Pomax' Kamermans Oct 25 '21 at 21:31
  • @Mike'Pomax'Kamermans my bad! i saw that and thought 'but where' and looked for an answer but only found people asking what i wanted to know. My bad! – a1cd Oct 25 '21 at 22:57
  • Using the LTS version of Node (V16) rather than V17 fixed this issue for us. – Janac Meena Dec 27 '21 at 22:46
  • I just have this issue and after I revert back to the v16 NodeJS, the error is gone. – Arefe Mar 26 '22 at 03:33
  • If you have come here with this error on NodeJS v18.x, the cause is the same. See https://web.archive.org/web/20220412174915/https://nodejs.org/api/crypto.html#support-for-weak-or-compromised-algorithms for details as to the cause, and follow the instructions to enable the OpenSSL legacy provider https://web.archive.org/web/20220416014625/https://nodejs.org/api/cli.html#--openssl-legacy-provider – Drazisil Apr 28 '22 at 02:47

30 Answers30

621

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.

Ajoy Karmakar
  • 6,499
  • 2
  • 7
  • 12
  • 6
    where do i put this? – a1cd Oct 25 '21 at 20:13
  • 1
    @Evergreen you have to define the variable when you are building --> in your npm run command (you can use export, SET or cross-env depending on your OS) – Alexy Oct 28 '21 at 07:23
  • 14
    For me this command fails `/usr/local/Cellar/node/17.0.1/bin/node: --openssl-legacy-provider is not allowed in NODE_OPTIONS` – Ben Winding Nov 13 '21 at 04:30
  • what about ```docker run --rm -v $(pwd):/usr/src -w="/usr/src" node:latest export NODE_OPTIONS=--openssl-legacy-provider && yarn build``` /usr/local/bin/docker-entrypoint.sh: 11: exec: export: not found @ajoy-karmakar – Hamid Shariati Nov 14 '21 at 06:12
  • 65
    An explanation would be in order. E.g., why is it necessary? What is it supposed to achieve? Why does it work? What are the security implications, if any? Why is this answer radically different from the other answers? Please respond by [editing (changing) your answer](https://stackoverflow.com/posts/69699772/edit), not here in comments (***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Nov 15 '21 at 00:36
  • Worked for me, windows 10 using gitbash terminal (with the unix commands option enabled during installation) – Kiee Nov 15 '21 at 13:37
  • Worked for me, thanks – Luca Iaconelli Nov 17 '21 at 10:05
  • 14
    This solution is not recomended, try to uninstall Node.js version 17+ and reinstall the Node.js version 16+. – Abdul Basit Rishi Nov 24 '21 at 08:30
  • 2
    did `set NODE_OPTIONS=--openssl-legacy-provider` It's giving the same error – Zeeshan Ahmad Khalil Nov 25 '21 at 20:57
  • @AbdulBasitRishi This worked well, thank you for posting. It seems like a very telling solution... is this an issue buried within the newest Node version or is it just incidental that reverting to the older version solves it? – formula-hunter Nov 29 '21 at 20:10
  • 1
    This solution worked for me! Thanks – Maria Dec 02 '21 at 22:13
  • Hi, please edit this and add windows command --> set NODE_OPTIONS=--openssl-legacy-provider. Thank you! – kame Jan 11 '22 at 13:33
  • Worked perfectly for me. Thanks very much! – J Steven Perry Jan 28 '22 at 04:29
  • 1
    For many using Linux doing a simple `export NODE_OPTIONS=--openssl-legacy-provider` is not a very efficient solution. Once your terminal session ends that change goes away. If you wanted to make this permanent you'd have to add it to something like ~/.bash_profile or ~/.bashrc. Regardless, as mentioned by others I think setting an environment variable to work around the problem feels a bit hacky. Better to revert to LTS version of node in my opinion. – Jake Killpack Jan 29 '22 at 20:19
  • 1
    I've this problem with node 16.13.2 – titusfx Feb 19 '22 at 18:39
  • 2
    Downgrading to 16.13.0 is not enough, and it still won't let you use `--openssl-legacy-provider`. To use this parameter, you must be on v17 and up, and the parameter must be placed inside your `package.json`, it won't allow you to just place it in the `NODE_OPTIONS` env var for security reasons. And then it still doesn't work. This will only become a bigger problem as more people move onto the v16 LTS as a lot of projects still depend on Webpack 4 – Maxim Therrien Feb 27 '22 at 23:21
  • I'm using `nvm`, so I just switched versions to: `16` and it worked perfectly. It wasn't required for me to define the SSL env variables. – Felix Aballi Apr 05 '22 at 19:48
  • How did you switch versions? – Erick Adam Apr 25 '22 at 20:34
  • Please go through the answer again. I have updated the answer. – Ajoy Karmakar Apr 26 '22 at 07:27
  • If you use multiple versions of node, it's best to use nvm and uninstall node all together. Then use node version manager to install the latest version using `nvm install lts && nvm use lts` – Quan Truong May 26 '22 at 02:02
293

In your package.json: change this line

"start": "react-scripts start"

to

"start": "react-scripts --openssl-legacy-provider start"
a1cd
  • 5,259
  • 2
  • 7
  • 26
Srujan
  • 3,086
  • 1
  • 6
  • 2
  • 38
    but note that `--openssl-legacy-provider` means you are now almost certainly [running with known insecure SSL](https://www.openssl.org/docs/manmaster/man7/OSSL_PROVIDER-legacy.html), so this might mitigate the symptom, but it probably doesn't fix the underlying problem. – Mike 'Pomax' Kamermans Oct 25 '21 at 21:29
  • 3
    But of cause, this is acceptable when running localhost. In the newly released VS 2022, starting a react-app from scratch, having VS 2022 creating a self-signed certificate for you, still causes the sample project to crash. This is also an issue when creating a react-project from scratch using NPM commandline "npx create-react-app react-core-test". I testet this in two distinct environments runnin WIndows 10 and Windows 11. – Thomas Williams Dec 03 '21 at 10:29
  • 2
    See Ashok's answer. It's the correct solution to keep SSL working without vulnerabilities and it worked for me. – Skystrider Dec 06 '21 at 19:53
  • 4
    I don't understand the implication that, somehow, using node 16 with openssl 1.x would be more secure than using node 17 with openssl 3 in legacy mode. OpenSSL made something stricter in v3. You're either defeating that restriction one way, or the other. Both approaches are probably equally insecure. – kojiro Dec 08 '21 at 16:58
  • 1
    https://nodejs.org/en/blog/release/v17.0.0/ – Stephane Jan 06 '22 at 23:12
  • your a rock star – loekTheDreamer Feb 18 '22 at 09:43
  • 1
    This has been solved in react-scripts 5: https://stackoverflow.com/a/71334532/2525299 – neo post modern Mar 03 '22 at 09:11
  • 1
    thanks, adding this parameter worked in my latest node version. I am impressed how node / react related commands keep breaking months after we create a solution and try to maintain it. – Junior Mayhé Apr 19 '22 at 19:28
205

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).

Ashok Bhobhiya
  • 2,152
  • 1
  • 4
  • 8
  • 8
    but... why is the new version incompatible with old code? node is one of the biggest programming tools in the world, they wouldn't just create a new version of nodejs that wasn't backwards compatible (i guess they would because they did but you get my point) – a1cd Oct 31 '21 at 19:25
  • 2
    Forceful downgrade – NetEmmanuel Nov 12 '21 at 12:15
  • Thanks, It's great. It worked well after uninstalling nodejs version 17.1.0 and reinstall nodejs version 16.13.0. – Son Cao Nov 18 '21 at 13:51
  • 11
    Always use LTS for real applications, it fixed the issue. – Krishnadas PC Nov 20 '21 at 05:42
  • solved after downgrade NodeJs from version 17 to version 16 LTS. – Ayman Al-Absi Dec 07 '21 at 18:37
  • 1
    Is the new LTS after 16 supposed to revert back to old SSL? I am assuming the problem will be the same, just deferred until later, and using LTS 16 is a temporary solution. – trusktr Dec 21 '21 at 04:24
  • Worked for me, instead of typing the version use `nvm instal lts` and `nvm use lts`. – José Tomás Tocino Dec 26 '21 at 02:49
  • This was messing me up too. I had multiple versions installed including v17.2.0. It's best to uninstall versions that are not LTS: `nvm uninstall v17.2.0` – Ian Newland Jan 18 '22 at 02:53
  • 1
    https://nodejs.org/en/about/releases/ and https://render.com/docs/node-version seem like they'll be helpful for me. – Ryan Feb 22 '22 at 19:38
55

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.

Heretic Monkey
  • 11,078
  • 7
  • 55
  • 112
davychhouk
  • 1,049
  • 15
  • 18
51

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.

Gary Bao 鲍昱彤
  • 1,876
  • 16
  • 23
  • 6
    Confirming that downgrading version to `V.16` fixed the issue. `nvm install v16 && nvm alias default v16 && nvm use v16` . – Manuel Lazo Dec 16 '21 at 17:15
  • 1
    Downgrading from v17 to v16 fixes the issue – onmyway133 Jan 07 '22 at 09:52
  • 1
    Yes this solution works perfectly. I've V17 in my workstation and facing this issue. Whereas the same `package.json` in my GitHub action uses V16 and this error is not happening. Thanks! – Saravanan G Jan 17 '22 at 19:18
30

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
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Ritesh Kumar
  • 301
  • 2
  • 2
  • 5
    Thanks, it worked. But can you explain why this is happening and how this command fixes the problem? – Ali KHalili Nov 07 '21 at 06:03
  • Worked for me thanks, but this is not a permanent solution. – Abdul Basit Rishi Nov 09 '21 at 09:58
  • @AliKHalili This github link explains it :- https://github.com/webpack/webpack/issues/14532#issuecomment-947012063 – Ritesh Kumar Nov 09 '21 at 13:33
  • @AbdulBasitRishi Yes, sadly it is not. The easier one would be downgrade the node version. Seems like a new version issue in Node. Probably they will fix it – Ritesh Kumar Nov 09 '21 at 13:40
  • This is essentially a duplicate of [Ajoy Karmakar's answer](https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported/69699772#69699772) (also without any explanation whatsoever). – Peter Mortensen Jan 02 '22 at 02:38
20

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).

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
ViktorMS
  • 556
  • 4
  • 19
19

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
ati hy
  • 191
  • 1
  • 3
  • this is weirdly worded :| try using the ` character around code [markdown help](https://stackoverflow.com/editing-help#code) – a1cd Oct 24 '21 at 15:27
  • 4
    Version v16.13.0 instead of 17.x worked as well for me. I also didn't need to delete the `node_modules` folder. – Tigerware Oct 28 '21 at 06:51
  • I'm running node version 14.17.3 and I'm still having this issue. – brohjoe Mar 23 '22 at 23:01
15

This solution worked for me.

This error is coming in Node.js version 17+, so try to downgrade the Node.js version.

  1. Uninstall Node.js from the computer.
  2. Download Node.js version 16 and install it again from https://nodejs.org/download/release/v16.13.0/

That's all.

Abdul Basit Rishi
  • 1,761
  • 19
  • 27
  • 2
    but why? Why did node v17 have problems – a1cd Nov 11 '21 at 20:56
  • 2
    @Evergreen This is most likely a webpack4 issue, also in version 17 Node.js developers have deprecated of trailing slash pattern mappings which is unsupported in the import maps specification. Node.js developers needs to resolve this asap. – Abdul Basit Rishi Nov 12 '21 at 08:21
  • 1
    yea, i would expect node js, being such a widely used product, would have a bit more care put into backwards compatibility. – a1cd Nov 13 '21 at 16:02
  • 1
    or, if you're using nvm (node version manager) (and if you're not, you should be, so take this moment to do so...), you can just type `nvm install 16` and you're good to go. – Kyle Baker Nov 24 '21 at 19:38
15

check

node -v
v17.4.0

then roll back to node --lts (node v16.13.2 (npm v8.1.2)) for that use nvm

official install 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

Dorian
  • 4,760
  • 1
  • 28
  • 43
14

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Santosh Karanam
  • 838
  • 9
  • 20
  • NODE_OPTIONS=--openssl-legacy-provider is command line argument which should be present when you run yarn build. Nothing to do with Docker. When you build docker image of your application above line is what you use to build – Santosh Karanam Nov 02 '21 at 12:42
  • This is a near-duplicate of [Ajoy Karmakar's answer](https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported/69699772#69699772). This one is also missing an explanation. Can you please provide an explanation? E.g., why is `--openssl-legacy-provider` necessary? Why all the `yarn` stuff? Please respond by [editing (changing) your answer](https://stackoverflow.com/posts/69749630/edit), not here in comments (***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Jan 02 '22 at 02:31
  • The answer above runs in docker file with yarn as package manager. This will help users who are using similar environments and unable to resolve with other answers provided. Ill edit the answer with more explanation. Thanks – Santosh Karanam Jan 04 '22 at 15:10
7

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
...
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
briancollins081
  • 658
  • 6
  • 17
5

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- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Install latest LTS version:

nvm install --lts

Use LTS version:

nvm use --lts

Done!

Source: https://itsmycode.com/error-digital-envelope-routines-unsupported/

Pablo Yabo
  • 2,460
  • 2
  • 24
  • 32
4

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
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
4

Same Error with node version v18.0.0 and nuxt framework version 2.15 when running dev server and will be fixed by:

"scripts": {
  "dev": "NODE_OPTIONS=--openssl-legacy-provider nuxt"
}
Art Mary
  • 424
  • 3
  • 10
3

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).

neo post modern
  • 1,374
  • 12
  • 27
3

Running audit fixed the problem for me

npm audit fix --force
Karthik Rana
  • 1,003
  • 1
  • 8
  • 19
2

I was facing the same issue with Node.js 17.0.1. I solved it by following these steps:

  • Open Control PanelProgram and FeaturesNode.js and uninstall Node.js by right-clicking a

  • Go to website https://nodejs.org/en/ and download the version and install.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
2

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
MELLAL Fethi
  • 99
  • 1
  • 5
2

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).

FXLima
  • 71
  • 1
  • 4
  • my development environment: - Angular CLI: 12.2.1 - Node: 16.14.0 (Unsupported) - Package Manager: npm 7.5.6 - OS: win32 x64 – FXLima Feb 09 '22 at 17:42
2

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);
  };
}
Rob Juurlink
  • 3,831
  • 3
  • 17
  • 18
1

Try:

npm create react-app --template typescript foo --use-npm
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
webcoder
  • 999
  • 1
  • 6
  • 23
  • An explanation would be in order. E.g., what is the idea/gist? What does it do? How does it work? Why does it work? Please respond by [editing (changing) your answer](https://stackoverflow.com/posts/69791488/edit), not here in comments (***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Nov 15 '21 at 00:47
1

On Dockerfile you should add:

ENV NODE_OPTIONS=--openssl-legacy-provider
Oded BD
  • 2,148
  • 21
  • 26
  • Near duplicate: [Ajoy Karmakar's answer](https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported/69699772#69699772) (also without any explanation whatsoever) – Peter Mortensen Jan 02 '22 at 02:43
  • I wanted it to be clear how to use with Docker – Oded BD Jan 02 '22 at 12:37
1

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.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Nhu Ngoan
  • 11
  • 1
1

You need to update react-scripts to the latest version

npm update react-scripts --save
Matic Kogovšek
  • 1,376
  • 1
  • 8
  • 3
1

Running react with docker

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 node

to using

From node:16.* 

fixes this issue in docker.

  • This worked for me and I'm not using docker. Downgrading to node 16 fixed my problems. ` nvm use 16 rm -rf node_modules rm yarn.lock yarn install yarn build ` – adamwong246 Apr 04 '22 at 00:58
1

For 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 line npm start it will first set the NODE_OPTIONS to avoid the problem.

lienok
  • 618
  • 1
  • 6
  • 7
0

In a terminal (OS X), simply downgrade like so:

sudo n 16.13.0
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Andrew
  • 2,412
  • 5
  • 27
  • 47
0

fixed by using lts

echo "lts" > .nvmrc
nvm install
Dorian
  • 4,760
  • 1
  • 28
  • 43
  • 1
    can you explain more? – titusfx Feb 19 '22 at 18:38
  • @titusfx react native has a buggy script to find the path of the node executable, this sets the version to the latest stable version of node through node version manager. What I found is that even if node is in my path, if I have an ~/.nvm directory it's going to try to find use in nvm and fail, this sets the current node to be linked to the one in ~/.nvm and thus that react native can find – Dorian Feb 21 '22 at 11:16
0

If 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

Enes
  • 13
  • 4