前端npm start运行 报错error:0308010C

 问题描述

启动项目npm start时遇到报错error:0308010C

this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at BulkUpdateDecorator.hashFactory (D:\工作\ncmesw\changzhou-management\WEB\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\util\createHash.js:145:18)
    at BulkUpdateDecorator.update (D:\工作\ncmesw\changzhou-management\WEB\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\util\createHash.js:46:50)
    at RawSource.updateHash (D:\工作\ncmesw\changzhou-management\WEB\node_modules\@angular-devkit\build-angular\node_modules\webpack-sources\lib\RawSource.js:77:8)
    at NormalModule._initBuildHash (D:\工作\ncmesw\changzhou-management\WEB\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:880:17)
    at handleParseResult (D:\工作\ncmesw\changzhou-management\WEB\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:946:10)
    at D:\工作\ncmesw\changzhou-management\WEB\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:1040:4
    at processResult (D:\工作\ncmesw\changzhou-management\WEB\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:755:11)
    at D:\工作\ncmesw\changzhou-management\WEB\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\NormalModule.js:819:5 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v18.19.1

原因

出现这个错误是因为 node.js V17版本中最近发布的OpenSSL3.0, 而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响.

解决办法

可以在配置中 运行和打包代码加上--openssl-legacy-provider 如下 start 指令 和 prod指令

"start": "node --openssl-legacy-provider -max-old-space-size=8048 ./node_modules/@angular/cli/bin/ng serve",
"prod": "node --openssl-legacy-provider --max-old-space-size=8048 ./node_modules/@angular/cli/bin/ng build --configuration production --build-optimizer"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值