You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行npm run build时出现“Failed to minify...”错误如何解决?

解决方案
  • 清理依赖缓存并重装
    执行以下命令重置依赖环境:

    npm cache clean --force
    rm -rf node_modules package-lock.json  # Windows系统执行:rmdir /s /q node_modules && del package-lock.json
    npm install
    

    完成后再次尝试运行 npm run build

  • 确保NODE_ENV环境变量正确设置
    构建命令需要在production环境下执行,手动指定环境变量后再构建:

    • Mac/Linux:
      export NODE_ENV=production
      npm run build
      
    • Windows(CMD):
      set NODE_ENV=production
      npm run build
      
  • 使用npm ci安装精确依赖版本
    避免子依赖自动更新引发的冲突,执行:

    rm -rf node_modules package-lock.json
    npm ci
    npm run build
    
  • 排查项目配置文件是否被误改
    检查.env文件、src目录下的配置代码、public目录中的静态资源是否有意外修改,这类变更可能导致构建失败

  • 调整react-scripts版本
    尝试升级到同系列的稳定版本(如2.1.8):

    npm install react-scripts@2.1.8 --save
    

    或回退到之前能正常构建的版本(若有记录)

内容的提问来源于stack exchange,提问作者Ashish Shravanekar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 05:36:19