[Solved] npm Error: error:0308010C:digital envelope routines::unsupported

error:0308010C:digital envelope routines::unsupported
This error occurs because of the recent release of OpenSSL3.0 in node.js V17 version, and OpenSSL3.0 adds strict limits on allowed algorithms and key sizes, which may affect the ecosystem cause some impact.

Some applications that can run normally before node.js V17, but in V17 and above versions may throw the following exceptions:

node:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports.__webpack_modules__.57442.module.exports (/Users/workspace/React/umiapp/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:135907:62)
    at NormalModule._initBuildHash (/Users/workspace/React/umiapp/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:109317:16)
    to handleParseError ( /Users/workspace/React/umiapp/node_modules/@umijs/deps/compiled/webpack/ 4 /bundle4.js: 109371 : 10 )
    at /Users/workspace/React/umiapp/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:109403:5
    at /Users/workspace/React/umiapp/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:109258:12
    at /Users/workspace/React/umiapp/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:61157:3
    at iterateNormalLoaders (/Users/workspace/React/umiapp/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:60998:10)
    at Array.<anonymous> (/Users/workspace/React/umiapp/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:60989:4) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.7.0
✨  Done in 1.92s.

It is said that this can be temporarily fixed by running the following command line

export NODE_OPTIONS=--openssl-legacy-provider

But the current test does not work, so I reinstalled node-v16.12.0, and npm also installed the corresponding version

Refer to https://nodejs.org/en/download/releases/ for the correspondence between node and npm versions

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *