以前的几个老项目,再升级Node后启动报错,错误信息如下:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:79:19)
    at Object.createHash (node:crypto:139:10)
    at module.exports (F:\ProCode\FundManagement-Admin\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (F:\ProCode\FundManagement-Admin\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (F:\ProCode\FundManagement-Admin\node_modules\webpack\lib\NormalModule.js:471:10)
    at F:\ProCode\FundManagement-Admin\node_modules\webpack\lib\NormalModule.js:503:5
    at F:\ProCode\FundManagement-Admin\node_modules\webpack\lib\NormalModule.js:358:12
    at F:\ProCode\FundManagement-Admin\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (F:\ProCode\FundManagement-Admin\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (F:\ProCode\FundManagement-Admin\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (F:\ProCode\FundManagement-Admin\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at F:\ProCode\FundManagement-Admin\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
    at F:\ProCode\FundManagement-Admin\node_modules\graceful-fs\graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3) {
  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'
}

解决方案:
1、在项目的package.json中修改如下:

{
  ...
  "scripts": {
    "dev": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service serve",
    "build": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service build",
    ...
  },
  ...
}

2、在系统环境变量中配置如下:
20240722090010.png

完成以上两步后重启电脑,然后再次启动项目,完美运行。

标签: digital envelope routines::unsupported, node高版本运行老旧项目, digital envelope routines

添加新评论