Error: error:0308010C:digital envelope routines::unsupported

报错

(node:16863) [DEP_WEBPACK_CONFIGURATION_OPTIMIZATION_NO_EMIT_ON_ERRORS] DeprecationWarning: optimization.noEmitOnErrors is deprecated in favor of optimization.emitOnErrors

(Use node --trace-deprecation ... to show where the warning was created)

(node:16863) [DEP_WEBPACK_COMPILATION_OPTIMIZE_CHUNK_ASSETS] DeprecationWarning: optimizeChunkAssets is deprecated (use Compilation.hooks.processAssets instead and use one of Compilation.PROCESS_ASSETS_STAGE_* as stage option)

(node:16863) [DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK] DeprecationWarning: Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader

node:internal/crypto/hash:71

this[kHandle] = new _Hash(algorithm, xofLen);

^

Error: error:0308010C:digital envelope routines::unsupported

at new Hash (node:internal/crypto/hash:71:19)

at Object.createHash (node:crypto:133:10)

问题原因

出现这个错误是因为 node.js V17版本中最近发布的OpenSSL3.0, 而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响.

解决方式

运行指令前设置环境变量

复制代码
export NODE_OPTIONS=--openssl-legacy-provider 

或者修改下脚本

复制代码
  "scripts": {
    "analyze": "cross-env ANALYZE=1 umi build",
    "build": "export NODE_OPTIONS=--openssl-legacy-provider &&  umi build",
    "deploy": "npm run build && npm run gh-pages",
    "dev": "export NODE_OPTIONS=--openssl-legacy-provider &&  npm run start:dev",
相关推荐
JaredYe6 小时前
纯 Node.js 编译 LaTeX:无需 TeX Live、无需宏包管理的工程级方案(node-latex-compiler)
node.js·latex·tectonic
_Kayo_10 小时前
Node.JS 学习笔记8
笔记·学习·node.js
six+seven10 小时前
Node.js内置模块fs
前端·node.js
wuhen_n11 小时前
Webpack vs Vite:前端构建工具对比
前端·webpack·node.js·vite
Gogo81611 小时前
Node.js 后端架构的“隐秘角落”:从 Fastify 引擎到类型系统的博弈
架构·node.js
本妖精不是妖精12 小时前
CentOS 7 安装 Node.js v18.x 完整教程
linux·centos·node.js
还是码字踏实1 天前
智能体平台Dify的 模型接口与 Agent 架构深度解析
react·抽象工厂模式·function call·模型插件系统
摇滚侠1 天前
Node.js 零基础教程,Node.js 和 NPM 的安装与使用
前端·npm·node.js
Ashley_Amanda1 天前
Node.js 服务搭建:从零到部署的生产级指南
node.js
天远云服1 天前
Node.js实战:天远车辆出险查询API接口调用流程、代码接入与场景应用
大数据·node.js