Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Node.js refuses --openssl-legacy-provider in NODE_OPTIONS

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

Short answer

The flag only exists in Node.js 17 and newer, and in 16.17 and newer on the 16 line. An older Node.js, often picked by a different shell, CI image or nvm default, rejects it when it starts. Check node -v where the error happens, then upgrade Node.js or remove the variable.

  • Applies to Node.js 16.17, Node.js 18, Node.js 22, npm 10
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the Node.js version and the variable in the same shell where the error shows. A mismatch with your editor or CI is common.

    node -v
    echo "$NODE_OPTIONS"
  2. 2Match what you see, then jump to its fix

    1. 1node -v prints a version older than 16.17 (v14, v12, early v16)This Node.js version does not know the flagFix
    2. 2The flag works in your terminal but fails in CI, in a Docker image, in an editor task or after nvm useNODE_OPTIONS is set where a different Node.js runsFix

What does the error look like?

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

Cause 1 of 2

This Node.js version does not know the flag

1Check

The Node.js CLI page lists the flag as added in v17.0.0 and v16.17.0. An older runtime sees an unknown option in NODE_OPTIONS and exits at startup, before your script runs.

node -v
node --openssl-legacy-provider -p "'accepted'"

2Fix

Move to a current release. With nvm, install the latest version and make it the default. The flag is then valid, though a project on a modern toolchain usually no longer needs it.

nvm install node
nvm alias default node

3Verify

A new shell reports a recent version, and the command that failed runs.

node -v
npm run build

Confirmed by nodejs.org

Did this fix it?

Cause 2 of 2

NODE_OPTIONS is set where a different Node.js runs

1Check

NODE_OPTIONS is read by every Node.js process that starts, so a value copied into a script, .env file or CI variable also reaches whichever Node.js that environment installed. Compare the version there with your own.

env | grep NODE_OPTIONS
node -v

2Fix

Make both sides use the same Node.js version, for example with an .nvmrc file, or clear the variable where the Node.js is too old.

unset NODE_OPTIONS
# or pin the version nvm reads
echo "22" > .nvmrc
nvm use

3Verify

The same command now starts in that environment.

node -p "process.version"

Confirmed by nodejs.org

Did this fix it?

How do I stop it coming back?

  • Pin one Node.js version for local work and CI, and print it at the start of the CI job.
  • Set NODE_OPTIONS on the one command that needs it and not in a global profile.
  • Remove the flag once your bundler has been upgraded and the build passes without it.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.