Node.js refuses --openssl-legacy-provider in NODE_OPTIONS
node: --openssl-legacy-provider is not allowed in NODE_OPTIONSShort 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.
Fix it fast
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"2Match what you see, then jump to its fix
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 node3Verify
A new shell reports a recent version, and the command that failed runs.
node -v
npm run buildConfirmed by nodejs.org
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 -v2Fix
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 use3Verify
The same command now starts in that environment.
node -p "process.version"Confirmed by nodejs.org
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
Node.js build stops with 'digital envelope routines::unsupported'
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ]
Node.js 17 and newer ship OpenSSL 3, which no longer loads old algorithms such as MD4 by default.
2 causes, each with a fixBack 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 fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack 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 fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fix