Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emit attempted before Angular Webpack plugin initialization

When I try to load the project, the following error is thrown

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit attempted before Angular Webpack plugin initialization.

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit attempted before Angular Webpack plugin initialization

.

like image 383
loki_cap Avatar asked Aug 08 '26 06:08

loki_cap


2 Answers

I got that error after upgrading Angular, since I ended up with invalid tsconfig. Check your tsconfig.json and your tsconfig.app.json, check any paths set (in files/include/exclude) are actually matching your environment. Either update paths or move the config files.

"files": [
  "../src/main.ts", // added ../ to reflect current file structure
  "../src/polyfills.ts"
],
like image 193
ccondrup Avatar answered Aug 09 '26 22:08

ccondrup


I had the same error, but required a different resolution. Turns out I was using an unsupported version of typescript (4.9.x) I had to downgrade it to the correct 4.8.x version to get the error to clear.

like image 20
Chris Stillwell Avatar answered Aug 09 '26 23:08

Chris Stillwell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!