2

I have an Angular App that doesn't seem to build with the prod configuration. I get the following error:

 Index html generation failed.
 undefined:9:219187: property missing ':'
 npm ERR! code ELIFECYCLE
 npm ERR! errno 1
 npm ERR! JI.Infopool.WebApp@0.0.0 build: `ng build --outputHashing=all "--configuration=prod"`
 npm ERR! Exit status 1
 npm ERR!
 npm ERR! Failed at the JI.Infopool.WebApp@0.0.0 build script.
 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The normal build works fine and I don't think that I changed any of the run configurations. I couldn't find anything useful in the log file either. Here's the config in the angular.json file:

"prod": {
          "baseHref": "/myApp/",
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true,
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ]
        },
R. Richards
  • 24,603
  • 10
  • 64
  • 64
Maxim
  • 227
  • 2
  • 14
  • Does this answer your question? [Angular 12 Index html generation failed error](https://stackoverflow.com/questions/67742918/angular-12-index-html-generation-failed-error) – The Chairman Feb 21 '22 at 15:08

3 Answers3

4

Just change `angular.json' file like this:

      "configurations": {
            "production": { // <=
              "optimization": { //<= add this 
                "scripts": true, 
                "styles": { 
                 "minify": true, 
                 "inlineCritical": false 
                }
               },
              "budgets": [...]
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 21 '22 at 08:39
1

there are some reasons may not generate the index file cause of minificaion on of errored css and script files or you may access the commonjs file. or external files like google fonts all are require internet at build time.

"optimization": { "scripts": true, "styles": { "minify": true, "inlineCritical": true }, "fonts": true }

please refer this link for more details https://angular.io/guide/workspace-config#optimization-configuration

hazan kazim
  • 938
  • 9
  • 11
0

For me this happened after angular 15 upgrade and making the optimization false was the only thing helped me to resolve the issue.

Saiteja Samala
  • 111
  • 2
  • 7