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

一、问题描述

今天运行yarn run dev命令,出现ERROR Error: error:0308010C:digital envelope routines::unsupported错误:

yarn run v1.22.19
$ vue-cli-service serve
 INFO  Starting development server...
95% emitting CompressionPlugin ERROR  Error: error:0308010C:digital envelope routines::unsupported
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at D:\workspace\xxx-new\xxx-ui\node_modules\compression-webpack-plugin\dist\index.js:243:42
    at CompressionPlugin.compress (D:\workspace\xxx-new\xxx-ui\node_modules\compression-webpack-plugin\dist\index.js:284:9)      
    at D:\workspace\xxx-new\xxx-ui\node_modules\compression-webpack-plugin\dist\index.js:305:12
    at _next1 (eval at create (D:\workspace\xxx-new\xxx-ui\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:14:17)
    at eval (eval at create (D:\workspace\xxx-new\xxx-ui\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:33:1)   
    at D:\workspace\xxx-new\xxx-ui\node_modules\copy-webpack-plugin\dist\index.js:91:9
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

在这里插入图片描述

二、问题原因

看了错误栈,之前升级过Node版本,第一反应这个错误应该是和Node的版本有关(node升级版本过高)。
之前的Node版本16.18.0,而升级后的版本是18.14.0。新版本node.js( node 17+)使用了OpenSSL3.0对允许算法和密钥大小增加了严格的限制。

三、解决方案

(1)切换Node版本:
可以使用nvm来管理Node版本:
如果系统是Windows,可以参考《Windows 上安装nvm
如果系统是Mac OS,可以参考《Mac上安装nvm
(2)启用legacy OpenSSL provider
通过下面的命令行操作起来更容易:
Unix (Linux, macOS, Git bash等):

export NODE_OPTIONS=--openssl-legacy-provider

Windows:

set NODE_OPTIONS=--openssl-legacy-provider

PowerShell:

$env:NODE_OPTIONS = "--openssl-legacy-provider"

在这里插入图片描述

或在项目中的package.json文件下更改scripts加上这行代码:

SET NODE_OPTIONS=--openssl-legacy-provider &&

在这里插入图片描述

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晓风伴月

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值