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>
热门推荐
特斯拉投资者因马斯克460亿美元薪酬方案发生分歧
AGI发展全面综述,我们还要多久到达AGI?
肝功能化验单,都说了啥?
收藏!这些用眼护眼指南和良好用眼习惯请收好
如何搬运大型床垫?搬运大型床垫有哪些技巧?
“无痛”真的会对孩子不好吗?
曹冲之死:历史真相与野史传闻的辨析
香气四溢的秘诀:如何正确冲泡茉莉花茶!
《重返未来1999》游戏类型介绍
老一辈常说碗筷不能隔夜洗?到底有什么道理呢?都有什么讲究呢?
大蒜重茬减产的防治技术
故意驾车撞行为的刑事法律责任与处罚分析
重装系统不丢失数据:保留重要软件与文件的技巧
项目规划PPT单页制作指南:从主题设定到最终呈现
栎木与橡木的差异及家具制作特点
巧读《三十六计》|“无中生有”的两大关键策略
宝马M3和M4在动力性能方面的差异
1080p是1920x1080吗
日语考级N2级的具体考试内容有哪些
TOPS:揭秘AI算力的度量单位
清宫图里生男孩的月份
纯电动汽车如何办理上牌手续?办理纯电动汽车上牌需要准备哪些材料?
数控机床培训就业前景怎么样?难学吗要学多久,考好不如选对!
Pascal 编程语言:从辉煌到传承
右侧肋骨里面疼是什么原因
怀孕鼻塞睡不好怎么办?教你4个非药物缓解方式
床垫如何送上高层才能安全便捷?这种运输方式有哪些要点?
迎接首个“非遗版”春节 八成受访者更重视过年习俗
如何理解股票投资中的本金风险
光伏电站组串式逆变器并联谐振问题深度解析