LoginSignup
67
12

More than 1 year has passed since last update.

Node.js v17 で webpack error

Last updated at Posted at 2021-11-10

digital envelope routines::unsupported

Node.js が v17 になって以降(2021年10月19日) 、webpack (v5) で次のようなエラーがでるようになりました。

Webpack in development mode
[webpack-cli] Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
...
<anonymous>:6:1) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'

OpenSSL 3.0 のハッシュ関数に関する問題のようですが、webpack.config.js に「output.hashFunction: "xxhash64"」を追加すると、とりあえずビルドできます。

webpack.config.js
const config = {
...
	output: {
		hashFunction: "xxhash64",
...
	},

別の方法として、node の実行時オプションに「--openssl-legacy-provider」を追加してもOKです。この場合は、次のように環境変数を定義するのが簡単です。

export NODE_OPTIONS=--openssl-legacy-provider

なお、この問題は webpack の v6 で修正されるようです。

67
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
67
12