loki
loki

Reputation: 1115

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

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)

Upvotes: 100

Views: 362232

Answers (18)

mohsen gholami
mohsen gholami

Reputation: 1

Just typing in the PowerShell window is well done for me :

$env:NODE_OPTIONS =""

Upvotes: -1

broox
broox

Reputation: 3960

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.

Upvotes: 102

Shantnu
Shantnu

Reputation: 137

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

Upvotes: 1

Sahil Kashyap
Sahil Kashyap

Reputation: 359

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

Upvotes: 0

Kartikeya Saini
Kartikeya Saini

Reputation: 31

This worked for me

set NODE_OPTIONS=

Upvotes: 3

Michaël
Michaël

Reputation: 509

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.

Upvotes: 43

alreich
alreich

Reputation: 91

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"

Upvotes: 1

Edwin
Edwin

Reputation: 19

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.

Upvotes: 2

Nipun Ravisara
Nipun Ravisara

Reputation: 4471

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

Upvotes: 4

kbvishnu
kbvishnu

Reputation: 15640

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

Upvotes: 16

Akul Srivastava
Akul Srivastava

Reputation: 129

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

Upvotes: 4

Ronaldo Patterson
Ronaldo Patterson

Reputation: 11

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.

Upvotes: 1

Jay
Jay

Reputation: 1

Update NVM to v18, and then unset NODE_OPTIONS.

It will be OK!

Upvotes: -1

Bhavya Verma
Bhavya Verma

Reputation: 121

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

Upvotes: 9

Nisha
Nisha

Reputation: 470

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

nvm use v18

to solve the issue.

Upvotes: 37

rimkashox
rimkashox

Reputation: 1008

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

Upvotes: 21

Peter Minea
Peter Minea

Reputation: 76

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.

Upvotes: 6

راجہ مخلص
راجہ مخلص

Reputation: 1669

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

Upvotes: 0

Related Questions