Error error0308010Cdigital envelope routinesunsupported

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

项目npm run serve时报错:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:140:10)
    at module.exports (E:\project\trunk\node_modules\webpack\lib\util\createHash.js:90:53)
    at NormalModule._initBuildHash (E:\project\trunk\node_modules\webpack\lib\NormalModule.js:401:16)
    at handleParseError (E:\project\trunk\node_modules\webpack\lib\NormalModule.js:449:10)
    at E:\project\trunk\node_modules\webpack\lib\NormalModule.js:481:5
    at E:\project\trunk\node_modules\webpack\lib\NormalModule.js:342:12
    at E:\project\trunk\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (E:\project\trunk\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (E:\project\trunk\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (E:\project\trunk\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:43:16)
    at E:\project\trunk\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:79:9
    at E:\project\trunk\node_modules\graceful-fs\graceful-fs.js:115:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Error error0308010Cdigital envelope routinesunsupported_第1张图片

原因是版本不兼容引起的,执行以下命令即可

set NODE_OPTIONS=--openssl-legacy-provider

在这里插入图片描述

再次执行npm run serve,即可成功

你可能感兴趣的:(nodejs,node.js)