Node.js版本与项目兼容性问题解决方案:OpenSSL错误处理指南
创作时间:
作者:
@小白创作中心
Node.js版本与项目兼容性问题解决方案:OpenSSL错误处理指南
引用
CSDN
1.
https://blog.csdn.net/TullyL/article/details/144299826
在使用Node.js进行项目开发时,经常会遇到版本兼容性问题,特别是在处理OpenSSL相关操作时。本文将详细介绍一种常见的OpenSSL错误及其多种解决方案,帮助开发者快速定位并解决问题。
报错原因
这个错误是由于Node.js版本与项目的兼容性问题导致的。你遇到的是OpenSSL相关的错误,这在较新版本的Node.js中比较常见。
解决方案
方案1:设置环境变量(推荐)
在Windows命令行中运行以下命令:
set SET NODE_OPTIONS=--openssl-legacy-provider
然后重新运行:
npm start
方案2:降级Node.js
- 卸载当前的Node.js v22.11.0
- 安装Node.js v16.x LTS版本
- 重新运行:
npm install && npm start
方案3:修改package.json
将scripts部分的start命令修改为:
{
"scripts": {
"start": "set SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start"
}
}
建议使用方案1,因为这是最简单且不需要修改项目文件的方法。如果还是不行,可以尝试:
- 清除node_modules:
rm -rf node_modules
- 清除package-lock.json:
rm package-lock.json
- 重新安装:
npm install
- 设置环境变量:
set SET NODE_OPTIONS=--openssl-legacy-provider
- 启动项目:
npm start
这个问题主要是因为你使用的Node.js v22.11.0版本太新,而项目可能使用了一些较旧的依赖包。
Successful operation
详细报错
Microsoft Windows [版本 10.0.22000.2538]
(c) Microsoft Corporation。保留所有权利。
E:\React\react-bilibli-ToDoList>cd..
E:\React>cd weatherApp-Reactjs-master
E:\React\weatherApp-Reactjs-master>npm i && npm start
npm warn cleanup Failed to remove some directories [
npm warn cleanup [
npm warn cleanup 'E:\\React\\weatherApp-Reactjs-master\\node_modules\\watchpack-chokidar2',
npm warn cleanup [Error: EPERM: operation not permitted, rmdir 'E:\React\weatherApp-Reactjs-master\node_modules\watchpack-chokidar2\node_modules\string_decoder'] {
npm warn cleanup errno: -4048,
npm warn cleanup code: 'EPERM',
npm warn cleanup syscall: 'rmdir',
npm warn cleanup path: 'E:\\React\\weatherApp-Reactjs-master\\node_modules\\watchpack-chokidar2\\node_modules\\string_decoder'
npm warn cleanup }
npm warn cleanup ]
npm warn cleanup ]
Starting the development server...
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 (E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\NormalModule.js:471:10)
at E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\NormalModule.js:503:5
at E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\NormalModule.js:358:12
at E:\React\weatherApp-Reactjs-master\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (E:\React\weatherApp-Reactjs-master\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (E:\React\weatherApp-Reactjs-master\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
E:\React\weatherApp-Reactjs-master\node_modules\react-scripts\scripts\start.js:19
throw err;
^
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 (E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\NormalModule.js:417:16)
at E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\NormalModule.js:452:10
at E:\React\weatherApp-Reactjs-master\node_modules\webpack\lib\NormalModule.js:323:13
at E:\React\weatherApp-Reactjs-master\node_modules\loader-runner\lib\LoaderRunner.js:367:11
at E:\React\weatherApp-Reactjs-master\node_modules\loader-runner\lib\LoaderRunner.js:233:18
at context.callback (E:\React\weatherApp-Reactjs-master\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at E:\React\weatherApp-Reactjs-master\node_modules\babel-loader\lib\index.js:59:103 {
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'
}
Node.js v22.11.0
E:\React\weatherApp-Reactjs-master>
热门推荐
Epic与Steam游戏互通全攻略:跨平台联机不再是梦
走进红色教育基地|一座城市往昔与今朝的印记——走进“阳泉记忆·1947”文化园
水银中毒:症状、影响与预防措施
水银中毒的症状
买新能源车必看!2024电池安全选购避坑指南
当代情侣恋爱的精神状态:在快节奏社会中的情感追寻
南怀瑾的佛教经典书籍有哪些、南怀瑾佛学精讲系列
琴码在古筝中的重要性及如何选择合适的材质?
日本留学费用详解:学费、生活费及奖学金指南
探索构图在摄影中的重要性与技巧,提升你的视觉表达
父母在孩子成长中扮演五大角色
宋辽质子交换竟成大宋宫词硬伤!
糖友的“眩晕迷雾”:揭秘头晕背后的六大真相与应对秘籍
车辆剐蹭导致的民事纠纷及其法律解决途径
Android OpenGL ES详解——多重采样抗锯齿(MSAA)
对公路隧道施工过程中成本控制的研究
如何根据个人学习习惯制定个性化的考研复习计划?
塞上江南揽星河,神奇宁夏邀客来
邻里关系不和睦?试试这几个办法
羊身上最好吃的3个部位,肉贩都留着自己吃,很多人还不知道
肚脐眼右边平行3-5cm隐隐作痛?可能是这些疾病在作祟
权倾朝野、斗争复杂?明朝官场究竟什么样?
探索传统刀剑的钢材选择:你家宝剑用的是什么材料?
春季祛湿3大食疗秘诀:薏米、赤小豆、茯苓如何助你轻松排湿气
如何进行股票回本的分析?股票回本的策略有哪些局限性?
数字遗产继承的数据资产处置法律空白:数字永生时代的所有权困境
数字遗产继承的数据资产处置法律空白:数字永生时代的所有权困境
急性白血病应该怎么治疗
VirtualBox虚拟机零基础安装指南(2025新版)
日本旅行必备:关西交通卡攻略,请收藏好这份干货