Error message "node: --openssl-legacy-provider is not allowed in NODE_OPTIONS"
Asked Answered
R

18

91

This problem appeared after an update, sudo apt upgrade, on Ubuntu 20.04 (Focal Fossa).

Previously, I worked on versions Node.js v18.0.0 and npm 8.7.0, but after the update there was a problem. I ran command nvm install node --reinstall-packages-from=node, but it did not help.

Now I use npm v8.12.1 and Node.js v18.4.0.

When running the command npm start, I receive the message:

> [email protected] start
> cross-env PORT=10888 HTTPS=false react-scripts start --openssl-legacy-provider

node: --openssl-legacy-provider is not allowed in NODE_OPTIONS

part of a file, package.json, looks like this :

 "scripts": {
    "start": "cross-env PORT=10888 HTTPS=false react-scripts start --openssl-legacy-provider",
    "build": "react-scripts build",
    "predeploy": "npm run build",
    "deploy": "vk-miniapps-deploy",
    "tunnel": "vk-tunnel --insecure=1 --http-protocol=https --ws-protocol=wss --host=localhost --port=10888"
  },

I went back to version npm 8.7.0, npm install -g [email protected], but now even the output of Node.js version shows the same error:

node -v

Output:

node: --openssl-legacy-provider is not allowed in NODE_OPTIONS

Attempt to update:

nvm install 12.13.0

Output:

v12.13.0 is already installed.
Now using node v12.13.0 (npm v)
Roadhouse answered 5/7, 2022 at 9:10 Comment(1)
if someone ends up here who have lerna configuration then directly jumping on particular package setup, make sure you install, prepare and build all packages first. No need of any further changes required for --openssl-legacy-provider if it was already thereSlovak
D
6

You can try to perform an unset on the NODE_OPTIONS production variable. It can be done from the command line.

Your Node.js version seems already up-to-date (version 18). A similar problem was already treated and solved according to the GitHub page Running code via CLI triggers error: --openssl-legacy-provider is not allowed in NODE_OPTIONS #136599.

Didactic answered 7/7, 2022 at 20:33 Comment(1)
thanks, that helped! i also used the command nvm install 10 to fix the error : ERROR: npm is known not to run on Node.js v10.19.0 You'll need to upgrade to a newer Node.js version in order to use this version of npm. You can find the latest version at https://nodejs.org/Roadhouse
I
94

I ran into this on macOS. From Terminal, I ran export to check my environment variables and saw that NODE_OPTIONS=--openssl-legacy-provider had been set. I then simply ran unset NODE_OPTIONS and then was able to use Node.js again.

Inez answered 28/8, 2022 at 15:6 Comment(1)
This really help me, thanks! I had to execute the command inside my docker console, but it was fine!Rustic
T
52

Just run this command

unset NODE_OPTIONS
Teletype answered 17/10, 2022 at 9:38 Comment(2)
or in Windows: set NODE_OPTIONS=Brainstorm
This removes an environment variable. There must be more to it. Answers on Stack Overflow are expected to be standalone / self-contained. E.g., where does it go? In what sequence? When?Factory
P
34

For me unsetting NODE_OPTIONS alone didn't solve the problem. I had to use

nvm use v18

to solve the issue.

Puss answered 25/10, 2022 at 10:44 Comment(4)
Life saver. But I think I had to run unset NODE_OPTIONS before.Curule
on mac, this solved my problemHurl
On mac solved my problem as wellSketchbook
On mac, this was the issue for me. I did not have NODE_OPTIONS set so running nvm use v18 was the only thing I had to do.Secor
T
31

A Simple way through NPM.

We can set the SSL legacy option in the .npmrc file.

In my case Node.JS v18 with npm v9.

Add or edit the .npmrc file in your project folder and add the option:

node-options="--openssl-legacy-provider"

Advantages:

  • It can be managed per project
  • The .npmrc file in the project will remind us that the project needs to be updated.
  • If that appears in another project on the server we will still have the error.
Taft answered 3/5, 2023 at 8:33 Comment(4)
I resorted to using yarn. Not a solution if you must use npm, but this allowed me to continue. > yarn install DoneRoxana
Hi @HenkKruger, sorry I'm using NPM so I didn't search for yarn.Moire
Best solution for sure!Grindle
@Taft you're a life-saver. I needed to boot up a 10 year old project in a local environment and this worked without making the rest of my projects insecure.Contiguous
B
21

On Linux, you need to edit your /etc/ssl/openssl.cnf file to uncomment a few lines that will enable legacy provider support.

I am on Fedora 36; I had to change these lines:

##[provider_sect]
##default = default_sect
##legacy = legacy_sect
##
##[default_sect]
##activate = 1
##
##[legacy_sect]
##activate = 1

to:

[provider_sect]
default = default_sect
legacy = legacy_sect

[default_sect]
activate = 1

[legacy_sect]
activate = 1
Blepharitis answered 21/7, 2022 at 10:41 Comment(5)
Time saver, got this problem on Fedora 36 too. Thanks mate!Preterite
Just complementing these lines did not yet do the trick, do I need to restart something?Progeny
ok, I had to uncomment the section, then delete the node_modules and run npm install again. Then it even worked without --openssl-legacy-provider since I'm still running on node v16.14.0 on Fedora 36.Progeny
didn't work for me at all, so the solution was to install the nvm and use it to install the latest v16. github.com/nvm-sh/nvmFarandole
didn't work any solution except every time exportin node_options with flag. It happens when change node version in nvm from 14.17 to 16. after then, event downgrading to 14.21 is not solution for me (using yarn, not npm)Sitarski
N
13

Quick fix

You can try to downgrade the version. But as a quick fix, you can do the below options.

On Unix-like systems (Linux, macOS, Git Bash, etc.):

export NODE_OPTIONS=--openssl-legacy-provider

On the Windows command prompt:

set NODE_OPTIONS=--openssl-legacy-provider

In PowerShell:

$env:NODE_OPTIONS = "--openssl-legacy-provider"

Read more

Numskull answered 5/5, 2023 at 3:1 Comment(0)
I
8

I'm running macOS. I previously had Node.js version 18, which had this issue in my Node.js project:

Error message "error:0308010C:digital envelope routines::unsupported"

I downgraded the Node.js version to 16 LTS, and then it had this error:

node: --openssl-legacy-provider is not allowed in NODE_OPTIONS

The issue resolved by simply running the following command in the terminal.

unset NODE_OPTIONS
Illtempered answered 6/1, 2023 at 5:24 Comment(0)
D
6

You can try to perform an unset on the NODE_OPTIONS production variable. It can be done from the command line.

Your Node.js version seems already up-to-date (version 18). A similar problem was already treated and solved according to the GitHub page Running code via CLI triggers error: --openssl-legacy-provider is not allowed in NODE_OPTIONS #136599.

Didactic answered 7/7, 2022 at 20:33 Comment(1)
thanks, that helped! i also used the command nvm install 10 to fix the error : ERROR: npm is known not to run on Node.js v10.19.0 You'll need to upgrade to a newer Node.js version in order to use this version of npm. You can find the latest version at https://nodejs.org/Roadhouse
S
4

I had the same issue with React Native, ./gradlew assembleRelease.

I solved this by downgrading Node.js version to v18.17.0 and setting Node.js options as --openssl-legacy-provider

Commands

nvm install v18

nvm use v18

export NODE_OPTIONS=--openssl-legacy-provider
Satiate answered 26/7, 2023 at 12:48 Comment(0)
T
2

Two ways to fix it:

Way 1

Try resetting NODE_OPTIONS by running the following command:

export NODE_OPTIONS=""

Way 2

Upgrade to Node.js 18

nvm use v18
Tempt answered 24/4, 2023 at 6:19 Comment(0)
L
2

Using Node.js 18.18.2 and export NODE_OPTIONS=--openssl-legacy-provider to the start script:

"scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "export NODE_OPTIONS=--openssl-legacy-provider && react-native start",
    "test": "jest",
    "lint": "eslint ."
  },

solved my issue.

Lyle answered 13/11, 2023 at 10:23 Comment(0)
M
2

This worked for me

set NODE_OPTIONS=
Merriweather answered 14/4 at 12:1 Comment(2)
As opposed to using unset?Crematorium
Worked for me. "node-options=" doesn't work but "NODE_OPTIONS=" worked. ThanksMoney
A
1

The previous answers were good suggestions. However, what worked for me was commenting the entry in the .npmrc file located in my project folder as shown here.

Ardeliaardelis answered 21/3, 2023 at 18:1 Comment(1)
Please review Why not upload images of code/errors when asking a question? (e.g., "Images should only be used to illustrate problems that can't be made clear in any other way, such as to provide screenshots of a user interface.") and do the right thing (it covers answers as well). Thanks in advance.Factory
E
1

For me, I was on Node.js 16 and I just upgraded to Node.js v18 (NODE_OPTIONS may be a red herring).

Also, the variable was not exported to the env (so there wasn't any way to unset it), but it was part of the command (in package.json), i.e., "serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve"

Expectorant answered 19/12, 2023 at 13:45 Comment(0)
Q
0

I was facing Error on yarn start. Error screenshot is attached below

enter image description here

Now I fixed this by following steps: open pakage.json and change script object

  "scripts": {
  "android": "react-native run-android",
  "build_debug": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
  "ios": "react-native run-ios",
  "start": "cross-env NODE_OPTIONS= --openssl-legacy-provider start",
  "test": "jest",
  "lint": "eslint .",
  "android_apk": "npx react-native run-android --variant=release"
  
  },

with this

"scripts": {
    
        "android": "react-native run-android",
        "ios": "react-native run-ios",
        "build": "react-native run-android --mode=release",
        "lint": "eslint .",
        "start": "react-native start",
        "test": "jest"
      },

And second step I performed is that created a .env file in my React Native Project root directory and place the below code in it

NODE_OPTIONS="--openssl-legacy-provider"

And again run yarn start command

Quinquennium answered 17/8, 2023 at 10:21 Comment(1)
Please review Why not upload images of code/errors when asking a question? (e.g., "Images should only be used to illustrate problems that can't be made clear in any other way, such as to provide screenshots of a user interface.") and do the right thing (it covers answers as well). Thanks in advance.Factory
R
0

if you are new to React native development

and using mac m1 chip. using xcode,

it automatically opens up the terminal and runs npm start

This terminal might be using some other node version. my project was using node 14, but globally 16 was set.

You can choose one

  1. Globally set to 14 (other project might get affected) nvm alias default 14

  2. OR open a new terminal in the project directory

nvm use 14
npm start

and run xcode build start

Reticle answered 8/6 at 12:33 Comment(0)
M
0

Just to give a background I am using @angular/[email protected] for learning and education purpose. I was also getting "ERR_OSSL_EVP_UNSUPPORTED" error. Then i was running "node-options" but didn't worked for me. But "NODE_OPTIONS" worked for me. Below is my complete command which worked for me.

I am using PowerShell as my terminal.

$env:NODE_OPTIONS = "--openssl-legacy-provider"

npx -p @angular/[email protected] ng serve

Issue with this is that yo have to set it again and again when you close your IDE and run again and again. To resolve this issue I have found permanent solution.

I just ran.

npm config edit

it will add .npmrc in your window user directory and in that file we have to add

node-options=--openssl-legacy-provider

it will work and you don't have to run again and again.

.npmrc file config screenshot

Money answered 23/6 at 16:50 Comment(0)
B
-1

Update NVM to v18, and then unset NODE_OPTIONS.

It will be OK!

Bastogne answered 20/3, 2023 at 3:27 Comment(4)
This answer appears to be a duplicate of one already provided here.Decisive
Re "Update NVM to v18": How exactly?Factory
Re "Update NVM to v18": Do you mean "Update Node.js to v18"?Factory
Is this a completely bogus answer?Factory

© 2022 - 2024 — McMap. All rights reserved.