Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Production build fail after Angular upgrade document.documentElement.setAttribute is not a function

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

like image 462
ani.lava Avatar asked Sep 09 '25 20:09

ani.lava


1 Answers

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

like image 91
miscellian Avatar answered Sep 12 '25 10:09

miscellian