Maaz Zindani

Loading the index…

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

Node.js build stops with 'digital envelope routines::unsupported'

ErrorError: error:0308010C:digital envelope routines::unsupported

Short answer

Node.js 17 and newer ship OpenSSL 3, which no longer loads old algorithms such as MD4 by default. An old webpack 4 toolchain asks for MD4 when it hashes files, and the build dies with error:0308010C. Upgrade the toolchain to webpack 5, or as a stop-gap start Node.js with the legacy OpenSSL provider.

  • Applies to Node.js 22, webpack 5, 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 webpack version your project really uses. The error needs both an OpenSSL 3 runtime and an old bundler.

    node -p "process.version + ' / openssl ' + process.versions.openssl"
    npm ls webpack
  2. 2Match what you see, then jump to its fix

    1. 1The stack trace goes through webpack/lib/util/createHash.js (webpack 4) and the build runs on Node.js 17 or newerAn old webpack asks for the MD4 hashFix
    2. 2The same error, and the project is pinned to a toolchain you cannot change this weekYou cannot upgrade yet and need the build to run todayFix

What does the error look like?

  • Error: error:0308010C:digital envelope routines::unsupported
  • opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ]
  • library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED'

Cause 1 of 2

An old webpack asks for the MD4 hash

1Check

webpack 4 defaults its hash function to md4, and OpenSSL keeps MD4 in its legacy provider. If npm ls shows webpack 4.x, this is your cause.

npm ls webpack

2Fix

Move the project to a current toolchain. For an Angular app, run the official update steps for the next major version; webpack 5 is what current builders use. If you configure webpack yourself, upgrade it to 5.54 or newer, where output.hashFunction can be set to xxhash64.

npm install --save-dev webpack@5
# webpack.config.js
module.exports = {
  output: { hashFunction: 'xxhash64' },
};

3Verify

Run the build again on the same Node.js version. The error should be gone.

npm run build

Confirmed by webpack.js.org

Did this fix it?

Cause 2 of 2

You cannot upgrade yet and need the build to run today

1Check

Node.js has a switch that turns on the OpenSSL 3 legacy provider, which brings MD4 back. It can be passed through NODE_OPTIONS so that npm scripts pick it up.

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

2Fix

Set the flag for the build command only, not for your whole machine. Treat it as a bridge to the upgrade, because it keeps an outdated algorithm enabled.

# macOS / Linux
NODE_OPTIONS=--openssl-legacy-provider npm run build

# package.json (cross-platform, needs: npm i -D cross-env)
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider ng build"

3Verify

The build completes without the unsupported error.

NODE_OPTIONS=--openssl-legacy-provider npm run build

Confirmed by nodejs.org

Did this fix it?

How do I stop it coming back?

  • Keep Angular and its builder on a supported major version so the bundler is not years behind Node.js.
  • Pin the Node.js version in one place (.nvmrc or the engines field) and use the same one in CI.
  • Do not leave --openssl-legacy-provider in a script after the upgrade; remove it once 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.