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

发布于:2025-06-10 ⋅ 阅读:(21) ⋅ 点赞:(0)

E:\>
E:\>
E:\>cd E:\wanyun-ui

E:\wanyun-ui>
E:\wanyun-ui>
E:\wanyun-ui>npm run dev

> wanyun@3.8.6 dev
> vue-cli-service serve --openssl-legacy-provider

 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:79:19)
    at Object.createHash (node:crypto:139:10)
    at E:\wanyun-ui\node_modules\compression-webpack-plugin\dist\index.js:243:42
    at CompressionPlugin.compress (E:\wanyun-ui\node_modules\compression-webpack-plugin\dist\index.js:284:9)
    at E:\wanyun-ui\node_modules\compression-webpack-plugin\dist\index.js:305:12
    at _next1 (eval at create (E:\wanyun-ui\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:14:17)
    at eval (eval at create (E:\wanyun-ui\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:33:1)
    at E:\wanyun-ui\node_modules\copy-webpack-plugin\dist\index.js:91:9

方法 1:临时降级 Node.js 版本(推荐)

最稳定的方案是使用 Node.js 16.x(LTS 版本),它对旧项目兼容性更好。

  1. 卸载当前 Node.js(如已安装 17+ 版本)。

  2. 安装 Node.js 16.x(从官网下载:Node.js 16)。

  3. 重新运行 npm run dev


方法 2:强制启用 OpenSSL 旧版提供器(临时修复)

如果无法降级 Node.js,可以尝试以下两种方式启用旧版 OpenSSL:

方式一:修改 package.json 的 dev 脚本

在 scripts 中添加环境变量 NODE_OPTIONS

json

复制

下载

"scripts": {
  "dev": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve"
}
方式二:通过命令行临时设置(Windows)

直接运行:

bash

复制

下载

set NODE_OPTIONS=--openssl-legacy-provider && npm run dev

方法 3:升级或修复相关依赖

如果问题仍然存在,可能是 compression-webpack-plugin 版本过旧:

  1. 尝试升级它:

    bash

    复制

    下载

    npm install compression-webpack-plugin@latest --save-dev
  2. 或者暂时禁用压缩插件(不推荐生产环境用):

    javascript

    复制

    下载

    // vue.config.js
    module.exports = {
      chainWebpack: (config) => {
        config.plugins.delete('compression');
      }
    };

方法 4:全局配置 OpenSSL 兼容性(适用于其他工具)

在系统环境变量中添加:

  1. 变量名:NODE_OPTIONS

  2. 变量值:--openssl-legacy-provider

  3. 重启终端或 IDE。


网站公告

今日签到

点亮在社区的每一天
去签到