解决前端报错“opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ]”
报错“ opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ]”
报错信息
前端启动项目报错,报错信息如下:
$ yarn start
yarn run v1.22.21
$ cross-env UMI_ENV=dev umi dev
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
Bundle with webpack 5...
⏱️ MFSU Enabled
Starting the development server...
* Webpack █████████████████████████ building (10%) 0/2 entries 1/2 dependencies 0/1 modules 1 active
...odules\umi\node_modules\@umijs\preset-built-in\bundled\@pmmmwh\react-refresh-webpack-plugin\client\ReactRefreshEnt
ry.js
node:internal/crypto/hash:69
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:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:184161:18)
at BulkUpdateDecorator.update (D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:184062:50)
at OriginalSource.updateHash (D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack-sources2\index.js:1:51038)
at NormalModule._initBuildHash (D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:115961:17)
at handleParseResult (D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:116027:10)
at D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:116119:4
at processResult (D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:115836:11)
at D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:115900:5
at D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:35132:3
at iterateNormalLoaders (D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:34958:10)
at Array.<anonymous> (D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:34949:4)
at runCallbacks (D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:24341:15)
at D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:24514:4
at D:\桌面\fastapi-ui-ant-P12\node_modules\@umijs\deps\compiled\webpack\5\bundle5.js:33829:16 {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v18.18.0
Done in 17.70s.原因分析
由于Node.js和OpenSSL兼容性问题,您在执行yarn start期间遇到了ERR_OSSL_EVP_UNSUPPORTED错误。这个错误通常出现在Node.js 17版本及更高版本中,原因是在OpenSSL 3.0中默认禁用了某些加密功能。
解决问题
1. 设置环境变量
错误可以通过设置一个环境变量来解决,这可以告诉Node.js使用OpenSSL 3.0的传统提供者功能。
在Windows上(命令行):
set NODE_OPTIONS=--openssl-legacy-provider yarn start
在Windows上(Powershell):
$env:NODE_OPTIONS="--openssl-legacy-provider" yarn start
在macOS或Linux上:
export NODE_OPTIONS=--openssl-legacy-provider yarn start
这会临时地为当前会话设置环境变量。如果这解决了问题,您可能希望在环境中永久设置此更改,或者将其包含在项目启动脚本中。
2. 更新包脚本
或者,您可以通过修改package.json脚本,在运行项目时包含此环境变量:
"scripts": {
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider umi dev",
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider umi build"
}3. 升级或降级Node.js
如果上述解决方案不可行,考虑更改Node.js版本。早于17版本的Node.js版,或者最新的LTS版本,可能不会出现这个问题。
- 对于生产应用程序来说,降级到LTS版本(如16.x)可能是一个更稳定的解决方案。
- 如果您使用的是早期版本的Node.js,或者更高版本可能仍存在与OpenSSL 3.0相关的未解决问题,请考虑升级到最新的LTS版本。
总结
到此这篇关于解决前端报错“opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ]”的文章就介绍到这了,更多相关前端报错opensslErrorStack error:03000086内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
- node.js使用npm 安装插件时提示install Error: ENOENT报错的解决方法
- nodejs npm错误Error:UNKNOWN:unknown error,mkdir ''D:\Develop\nodejs\node_global''at Error
- nodejs和npm版本不匹配:ERROR: npm v9.5.1 is known not to run on Node.js
- 解决nodejs报错Error:EPERM:operation not permitted,mkdir‘xxxxxxxxxxxxxxxx‘
- 解决hadoop启动报错ERROR: Attempting to operate on hdfs namenode as root的方法
- 解决node报错Error: Cannot find module http-errors的问题
- Node.js报错信息Error: Cannot find module 'XXX'问题及解决
相关文章
Node.js中的文件系统(file system)模块详解
Node.js文件系统模块提供了丰富的方法,用于读取、写入、操作文件和目录,文件系统模块是Node.js强大而灵活的一部分,为文件操作提供了方便的API,本文给大家介绍Node.js中的文件系统(file system)模块,感兴趣的朋友一起看看吧2023-11-11


最新评论