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

Angular ng build无报错但未生成可部署的index.html文件求助

Angular构建后无法生成可用于Firebase托管的有效index.html文件

我尝试将Angular应用部署到Firebase,但执行ng build命令(无论是否添加--production参数)都无法生成可用于托管的有效index.html文件。

相关信息:

  • dist文件夹情况:
    Dist文件夹截图
  • ng serve状态:已解决ng serve过程中出现的所有警告与错误:
    ng serve无警告错误截图
  • angular.json配置:
{"$schema": "./node_modules/@angular/cli/lib/config/schema.json","version": 1,"newProjectRoot": "projects","projects": {"golfapp": {"projectType": "application","schematics": {},"root": "","sourceRoot": "src","prefix": "app","architect": {"build": {"builder": "@angular-devkit/build-angular:application","options": {"outputPath": "dist/golfapp","allowedCommonJsDependencies": ["whatwg-url","sweetalert2","@supabase/node-fetch"],"index": "src/index.html","browser": "src/main.ts","polyfills": ["zone.js"],"tsConfig": "tsconfig.app.json","assets": [{"glob": "**/*","input": "public"}],"styles": ["src/styles.css"],"scripts": [],"server": "src/main.server.ts","prerender": true,"ssr": {"entry": "server.ts"}},"configurations": {"production": {"budgets": [{"type": "initial","maximumWarning": "2MB","maximumError": "5MB"},{"type": "anyComponentStyle","maximumWarning": "20kB","maximumError": "40kB"}],"outputHashing": "all"},"development": {"optimization": false,"extractLicenses": false,"sourceMap": true,"fileReplacements": [{"replace": "src/environments/environment.ts","with": "src/environments/environment.development.ts"}]}},"defaultConfiguration": "production"},"serve": {"builder": "@angular-devkit/build-angular:dev-server","configurations": {"production": {"buildTarget": "golfapp:build:production"},"development": {"buildTarget": "golfapp:build:development"}},"defaultConfiguration": "development"},"extract-i18n": {"builder": "@angular-devkit/build-angular:extract-i18n"},"test": {"builder": "@angular-devkit/build-angular:karma","options": {"polyfills": ["zone.js","zone.js/testing"],"tsConfig": "tsconfig.spec.json","assets": [{"glob": "**/*","input": "public"}],"styles": ["src/styles.css"],"scripts": []}}}}}

已尝试的解决方案:

  • 解决ng build中的所有语法错误
  • 调整预算配置以避免警告
  • 将多个依赖包添加到angular.json的allowedCommonJsDependencies列表中

问题仍未解决,寻求帮助。

内容的提问来源于stack exchange,提问作者Peter W

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 04:34:55