4

I have upgraded my application to Angular 16 and upgrade went well and application is working as expected

But when I run the command for prod build

ng build --configuration=production

I got this error

Index html generation failed.
document.documentElement.setAttribute is not a function

I am not sure how to fix this as I don't have documentElement.setAttribute in my code

Setting optimization and buildOptimizer to false in angular.json does work but I know this is not right way to fix

any help or suggestion would be appreciated

ani.lava
  • 69
  • 6
  • I have a feeling that this is related to `inlineCritical`. Can you try to just disable it with : `"optimization": {"styles": {"inlineCritical": false }}` in your prod build ? – Matthieu Riegler Jul 12 '23 at 07:58
  • @MatthieuRiegler It worked perfectly but how this is different from **"optimization" : false** ? – ani.lava Jul 12 '23 at 08:34
  • `optimization` is a set of options which can be finely tuned see https://angular.io/guide/workspace-config#optimization-configuration. Since I could not reproduce your issue, could you try to narrow it down in a GitHub repo ? – Matthieu Riegler Jul 12 '23 at 08:46

1 Answers1

1

Try remove node_modules and package-lock.json then run npm install

miscellian
  • 11
  • 2
  • This solution worked for me! Re-created the package-lock.json and pushed the new one with the rest of the code – shivisuper Aug 18 '23 at 05:25