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蛇年瑞气盈门·精美红包封面PSD模版
“文化+”赋能文旅 促生“长安之旅”新活力
洗衣机功率分布及正确使用注意事项
胃疼和肚子疼的区别
租房看房要注意的细节,保障居住安全
李白最绝妙的100句诗词,最好能背下来,让你提升一个境界!
三国时期的女性风采——孙鲁班与孙鲁育
多汗不等于体虚,科学解析来了!
感冒痰多怎么办?医生告诉你实用祛痰技巧
无人机测绘与三维实景建模:从技术发展到应用实践
南泉斩猫的启示
同步发电机工作原理与建模
是叔侄,也是权臣与傀儡,多尔衮和顺治帝的恩怨纠葛
《末日时在做什么》:生存、信仰与人际关系的深刻思考与反思
梭罗:不要把生命消磨在碎片化中——随波逐流,是对人生最大的浪费
从一起血案看人物命运和家族历史
江西赣州高额彩礼现象调查:最高彩礼38万,可分期支付
从《火车进站》到《午夜巴黎》:“浪漫之都”巴黎的光影往事
游泳池怎么选靠谱的,水质好坏怎么分辨?试试这几招
被人力资源欺负怎么办呢
荨麻疹的原因、症状和缓解方法
为什么会打嗝?看完这篇你就知道了频繁发生可能是健康问题的信号
福建5A景区有哪些地方?福建10大5A级旅游景区大盘点!
茴香种植时间和方法 高产栽培技术与管理措施
用《道德经》学中文?别急,真有用!

2024年国庆、中秋双节饮食安全消费提示
买房费用大揭秘,如何做好购房预算?