Node.js で「error:0308010C:digital envelope routines::unsupported」が解決できない
Node.js 17 以降が OpenSSL 3 を採用し、webpack 4 系など古いツールが使う非推奨ハッシュが拒否されるためです。
ツールを更新するか、暫定的に --openssl-legacy-provider を付けて回避します。
公開:
要約
Error: error:0308010C:digital envelope routines::unsupported は、Node.js 17 以降が同梱する OpenSSL 3 が、webpack 4 系などの古いビルドツールが使う非推奨ハッシュアルゴリズムを拒否することで発生します。
恒久対策はツールチェーンの更新、即効性のある回避は --openssl-legacy-provider の付与です。
よくある原因
- OpenSSL 3 への移行: Node.js 17 で OpenSSL 3 が標準になり、MD4 など弱いアルゴリズムが既定で無効化された。
- webpack 4 の内部依存: webpack 4 はチャンクのハッシュ生成に旧アルゴリズムを使うため、新しい Node でそのまま落ちる。
- 古い CRA / scripts:
react-scripts4 系などが webpack 4 を内包しており、Node を上げた瞬間に再現する。
解決策
1. 環境変数で暫定回避する
すぐビルドを通したい場合は legacy provider を有効化します。
export NODE_OPTIONS=--openssl-legacy-provider
npm run buildこのフラグは公式 CLI ドキュメント(新しいタブで開く)に記載された正式オプションですが、弱い暗号を許可する点に注意してください。
2. ツールチェーンを更新する(恒久対策)
webpack 5 系へ上げると根本解決します。
npm install webpack@latest webpack-cli@latest --save-dev
# CRA なら react-scripts を 5 以上へ
npm install react-scripts@latest3. Node のバージョンを固定する
更新が難しい既存プロジェクトは、.nvmrc で Node 16 系に固定する暫定運用も可能です。
ただし Node 16 は EOL のため、あくまで移行までのつなぎとし、最終的には依存更新を行ってください。
実行例
実際に上記の手順を node:20(v20.20.2 / OpenSSL 3.0.19)環境で動かすと、MD4 ハッシュを要求した時点で ERR_OSSL_EVP_UNSUPPORTED が発生し(終了コード 1)、--openssl-legacy-provider または NODE_OPTIONS 経由での付与によって解消されることが確認できます。
== versions ==
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
v20.20.2
Python 3.11.2
git version 2.39.5
This is not the tsc command you are looking for
To get access to the TypeScript compiler, tsc, from the command line either:
- Use npm install typescript to first add TypeScript to your project before using npx
- Use yarn to avoid accidentally running code from un-installed packages
v10.5.0
== run ==
--- Node.js / OpenSSL バージョン ---
v20.20.2
3.0.19
--- node hash.js (error:0308010C ... digital envelope routines::unsupported を想定)---
node:internal/crypto/hash:101
this[kHandle] = new _Hash(algorithm, xofLen, algorithmId, getHashCache());
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:101:19)
at Object.createHash (node:crypto:139:10)
at Object.<anonymous> (/tmp/tmp.6XDz9esosx/hash.js:3:18)
at Module._compile (node:internal/modules/cjs/loader:1521:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
at Module.load (node:internal/modules/cjs/loader:1266:32)
at Module._load (node:internal/modules/cjs/loader:1091:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
at node:internal/main/run_main_module:28:49 {
opensslErrorStack: [
'error:03000086:digital envelope routines::initialization error',
'error:0308010C:digital envelope routines::unsupported'
],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v20.20.2
終了コード: 1
--- 解消1: --openssl-legacy-provider で legacy provider を有効化 ---
md4: 19c8b5f7626080fbb0944d4203f1c784
終了コード: 0
--- 解消2: NODE_OPTIONS 経由でも同じ(ビルドコマンドに渡す用途)---
md4: 19c8b5f7626080fbb0944d4203f1c784
終了コード: 0
--- 恒久対策の方向: 弱いハッシュに依存しない(sha256 は標準で通る)---
sha256: 24ad36a1afb9ce6cbebf8d6c383069df80e12f8f56ec1b602d0c8050724f4e30— 2026-06-20 時点の出力