0308010C:digital envelope routines::unsupported 错误处理

171次阅读
没有评论
node:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at BulkUpdateDecorator.hashFactory (C:\Users\wuwuwu\workspace\myapp\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:184161:18)      
    at BulkUpdateDecorator.update (C:\Users\wuwuwu\workspace\myapp\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:184062:50)
    at C:\Users\wuwuwu\workspace\myapp\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:107101:9
    at C:\Users\wuwuwu\workspace\myapp\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:33829: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'
}

原因

这个是因为v17以上 版本包含了近期发布的 OpenSSL 3.0,根据 OpenSSL 的发布策略,OpenSSL 1.1.1 将在 2023-09-11 结束支持,这个日期也在 Node.js v18 LTS 结束日期之前。因为 OpenSSL 3.0 对允许的算法和密钥大小增加了严格的限制,有用到hash加密的地方后产生错误。 简单的解决办法是运行的时候设置node选项为–openssl-legacy-provider

解决方案一

使用旧版本的OpenSSL,

Linux:

export NODE_OPTIONS=--openssl-legacy-provider 

Windows CMD:

set NODE_OPTIONS=--openssl-legacy-provider

PowerShell:

$env:NODE_OPTIONS = "--openssl-legacy-provider"

解决方案二

修改package.json,在之前加入SET NODE_OPTIONS=–openssl-legacy-provider,不过那么说明

set NODE_OPTIONS=–openssl-legacy-provider

解决方案三

降版本至Node.js 17 以下。

“dev”: “npm run start:dev “,
//改为如下:
“dev”: “set NODE_OPTIONS=–openssl-legacy-provider && npm run start:dev “

方案四

如果确定不要legacy SSL ,可以修改webpack- 和 react-scripts 的版本,执行如下安装

npm install –save-dev webpack@5.74.0 –legacy-peer-deps
npm install –save-dev react-scripts@5.0.1 –legacy-peer-deps
npm install –legacy-peer-deps –save

参考

正文完
 0
wujingquan
版权声明:本站原创文章,由 wujingquan 于2023-09-12发表,共计1887字。
转载说明:Unless otherwise specified, all articles are published by cc-4.0 protocol. Please indicate the source of reprint.
评论(没有评论)