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>
热门推荐
企业文化战略规划的主要目标是什么?
前沿:金属氢真的存在么?
《蓦然回首》:动画电影里的青春、梦想与友谊
全荞麦冷冻挤压面条:从实验室到餐桌的创新突破
历史趣谈:“一龙、二凤、三猪、四痞、五僧、六光武” 所指皇帝解读
男性为何会因控制欲杀人?从谷歌工程师杀妻谈起
不锈钢加工用什么刀片?正确选择提升加工效率
社会的基本要素是什么
熬夜到很晚后会耳鸣
这些家庭常备药 你吃对了吗
2025南通高中最新排名 南通优秀高中排行榜
π 上 了 大 用 场 !
经常胃痛的人怎么调理
从精致的利己主义说起:《被侮辱与被损害的人》中的三种利己主义
留学美国后该如何选择回国还是留在国外
Wi-Fi 网络连接不稳定?这些技巧帮你提升网络质量!
千焦与大卡的热量换算及其在饮食中的应用
尿蛋白小于0.5g了,但是肌酐却越来越高?揭示5点常被忽视的关键因素
憋气30秒会消失一个脑细胞吗
2024高考人数和录取人数:附全国本科录取率各省排名一览表
铁观音茶梗为什么有红色也有绿色的?
25届银行校招网申简历关键词优化
塞维利亚vs马洛卡数据前瞻 西班牙锋霸记得吗?
如何查询单位养老金信息?查询单位养老金时可能遇到哪些问题?
寺、庙、院、殿、宫、观、庵:中国古建筑名称详解
经济学门下的留学热门选择:国际经济与贸易专业
探寻海南宋氏家族足迹:宋氏祖居深度游览路线指南
画坛双璧,各领风骚—朱祖国与范曾艺术风格及市场影响力深度剖析
汽车AC开关是制冷还是制热?终于知道,冬天开启它的原因了……
战团系统官方详细介绍!暴雪最人性化的系统之一!简直太方便了!