59

This problem appeared after an update sudo apt upgrade on Ubuntu 20.04. Previously, I worked on versions node 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, node v18.4.0. When running the command npm start I recieve the message :

> mini-app@0.0.0 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 npm@8.7.0 but now even the output of node version shows the same error :

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

attempt to update :

nvm install 12.13.0
v12.13.0 is already installed.
Now using node v12.13.0 (npm v)
milenao
  • 707
  • 1
  • 6
  • 8
  • 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 there – Sumit Ramteke May 19 '23 at 02:08

17 Answers17

62

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

broox
  • 3,538
  • 33
  • 25
23

Just Run this command

unset NODE_OPTIONS
Ayman Elshehawy
  • 2,746
  • 23
  • 21
21

On Linux, you need to edit your /etc/ssl/openssl.cnf to un-comment 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
rimkashox
  • 978
  • 9
  • 14
  • 1
    Time saver, got this problem on Fedora 36 too. Thanks mate! – Nicolas W. Aug 08 '22 at 15:33
  • 1
    Just complementing these lines did not yet do the trick, do I need to restart something? – white_gecko Aug 17 '22 at 09:10
  • 4
    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. – white_gecko Aug 17 '22 at 10:03
  • didn't work for me at all, so the solution was to install the nvm and use it to install the latest v16. https://github.com/nvm-sh/nvm – Oleksii Donoha Nov 24 '22 at 17:07
  • 1
    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) – Sinneren Jan 18 '23 at 09:14
21

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

nvm use v18 

to solve the issue

Nisha
  • 311
  • 2
  • 3
11

Simple way throught NPM.

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

In my case NodeJS v18 with npm v9

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

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

Advantages:

  • It can be manage per project
  • The .npmrc file in the project will remind us that the project needs to be updated.
  • If that appear on other project in the server we will still have the error.
Michaël
  • 141
  • 1
  • 7
8

I'm running macOS. I previously had Node Version 18, which had this issue in my NodeJs Project

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

I downgraded the Node 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

Hope this helps! :)

Adem kriouane
  • 381
  • 20
Bhavya Verma
  • 101
  • 1
  • 6
5

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

Your Node version seems already up-to-date (version 18). A similar problem was already treated and solved according to the following Github link: https://github.com/microsoft/vscode/issues/136599

E_net4
  • 27,810
  • 13
  • 101
  • 139
  • 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/` – milenao Jul 08 '22 at 07:26
5

I installed a new version but not did use

nvm use node
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
5

QUICK FIX

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

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

export NODE_OPTIONS=--openssl-legacy-provider

On Windows command prompt:

set NODE_OPTIONS=--openssl-legacy-provider

On PowerShell:

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

Read more

kbvishnu
  • 14,760
  • 19
  • 71
  • 101
1

Two ways to fix it-

WAY 1

Try reseting NODE_OPTIONS by running following command

export NODE_OPTIONS=""

WAY 2

Upgrade to Node 18

nvm use v18
0

update NVM to v18,

then unset NODE_OPTIONS

WILL BE OK!

Jay
  • 1
  • This answer appears to be a duplicate of one already provided [here](https://stackoverflow.com/a/74192831/6951294). – sloppypasta Mar 27 '23 at 23:59
0

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

0

I had the same issue with react-native ./gradlew assembleRelease.

Solved this by downgrading node version to v18.17.0 and setting node options as --openssl-legacy-provider

Commands

nvm install v18

nvm use v18

export NODE_OPTIONS=--openssl-legacy-provider
Nipun Ravisara
  • 3,629
  • 3
  • 20
  • 35
0

This will happen when someone using/moving to an older version of node JS possibly by nvm.

Two possible solution

  1. Change nvm to use node version 18 or above
  2. Remove export NODE_OPTIONS=--openssl-legacy-provider from npmrc by following below steps a. open ~/.npmrc b. remove line export NODE_OPTIONS=--openssl-legacy-provider from it and save
nirmal
  • 2,143
  • 1
  • 19
  • 29
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

راجہ مخلص
  • 1,177
  • 6
  • 15
-1

I had to run this also:

nvm install lts
SauravBhattacharya
  • 631
  • 3
  • 9
  • 24
-1

After trying everything suggested but still not working, I resorted to using yarn. Not a solution if you must use npm, but this allowed me to continue.

yarn install

Done

Henk Kruger
  • 177
  • 1
  • 4