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>
热门推荐
腰痛用药大揭秘:肿痛舒喷雾剂 vs 对乙酰氨基酚
80后张一鸣成中国新首富,宁波企业家54人登胡润榜
金秋雁门关:一日游遍18景,穿越千年古战场
中医调理慢阻肺,告别呼吸困扰
基因、身体机能与环境:头发生长速度差异的三大因素
西安大雁塔、大唐芙蓉园推出春节灯会,重现盛唐繁华
2025考研时间安排全解析,你准备好了吗?
男子因彩票欠9万,警示:中奖概率仅1772万分之一
大乐透最新开奖:选号技巧和兑奖全攻略
6步制作完美土豆泥:育空金土豆让口感更细腻
广场舞真的能延寿?听听专家怎么说
广场舞新手速成秘籍:13种基本步法大揭秘
广场舞:缓解压力的良方还是扰民的噪音?
余小坨带火广场舞,桃源社区科技治噪
普洱茶冲泡指南:如何选择适合8克茶叶的盖碗大小及使用技巧
震后气温骤降19度伴大风,西藏定日县救援工作紧急应对
种植牙术后护理:电动牙刷使用全攻略
正宁路夜市:兰州的美食地标与经济新引擎
人参养生茶:从功效到禁忌,一文读懂如何饮用
用好正负反馈,提升教育与人际交往效果
内心阴暗的人如何影响心理健康?
职场欺凌背后的“内心阴暗”
脚肿或藏致命风险,单侧持续需就医
一斤黄豆能出五斤豆腐,做豆腐原来这么简单,自己在家就能做
“豆腐”里有不少伪健康
哈佛大学研究告诉你:多吃豆腐少吃肉,真的能长寿
黄芪泡水,50岁夫妻养生新宠
50岁后夫妻相处的6大禁忌,你知道几个?
托伐普坦:治疗肝硬化腹水的新突破,显著改善患者生存质量
肝硬化腹水治疗新指南:利尿剂使用风险与管理方案