当前位置:   article > 正文

Error: error:0308010C:digital envelope routines::unsupported_yarn run v1.22.19 $ vue-cli-service serve info sta

yarn run v1.22.19 $ vue-cli-service serve info starting development server..

一、问题描述

今天运行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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

在这里插入图片描述

二、问题原因

看了错误栈,之前升级过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
  • 1

Windows:

set NODE_OPTIONS=--openssl-legacy-provider
  • 1

PowerShell:

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

在这里插入图片描述

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

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

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/491963
推荐阅读
相关标签
  

闽ICP备14008679号