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",
相关推荐
Richown12 小时前
全链路追踪:OpenTelemetry与Jaeger实战
区块链·react
008爬虫实战录17 小时前
【码上爬】 题十二:如来神掌 困难, JSVMP加密,使用代理补环境
前端·javascript·node.js
Richown17 小时前
容器编排:Kubernetes高级调度策略
区块链·react
008爬虫实战录21 小时前
【码上爬】 题九:webpack调试 堆栈分析
前端·webpack·node.js
xiaoxue..21 小时前
Node.js 笔试题讲解
后端·面试·node.js
小小前端仔LC1 天前
Node.js + LangChain +React:搭建个人知识库(四)- 把向量和文件切块存入mysql中
后端·node.js
海上彼尚1 天前
Nodejs也能写Agent - 7.基础篇 - MCP
前端·javascript·人工智能·node.js
Richown1 天前
自动化运维:Ansible与基础设施即代码
区块链·react
海兰1 天前
【实用程序】图片处理服务,前端应用 (Vue 3 + Pinia + Vite)后端服务 (Node.js + Express + Sharp)
前端·javascript·vue.js·node.js·pinia
Richown1 天前
微服务监控:Prometheus与Grafana实战
区块链·react