Skip to content

解决 vuepress 无法编译打包 #25

@zhangwt-cn

Description

@zhangwt-cn

出现问题

打算使用vuepress做博客,项目结构以及配置都按官方文档设置,运行npm run docs:dev也是正常的,但是npm run docs:build打包的时候一直报错,下面是部分报错日志

(undefined) assets/js/styles.8f3dca9f.js from Terser
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at /Users/zhangwentao/vscode/notes/node_modules/terser-webpack-plugin/dist/index.js:217:37
    at Array.forEach (<anonymous>)
    at TerserPlugin.optimizeFn (/Users/zhangwentao/vscode/notes/node_modules/terser-webpack-plugin/dist/index.js:160:259)
    at _next0 (eval at create (/Users/zhangwentao/vscode/notes/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
    at eval (eval at create (/Users/zhangwentao/vscode/notes/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:30:1)
(undefined) assets/js/1.7f771cfb.js from Terser

解决方法

有两种解决方法

  1. 降级node版本
    经过验证node 16 版本下npm run docs:build 是正常的,在node 18版本下运行就会出现这个错误
  2. 设置环境变量(未验证)
    具体的操作方式 nodejs 17: digital envelope routines::unsupported webpack/webpack#14532

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions