# Error: Module build failed (from ./node\_modules/@ngtools/webpack/src/ivy/index.js):

**URL:** <https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154>\
**Category:** Angular\
**Created:** [September 14, 2022, 1:03pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154 "2022-09-14T13:03:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakista80](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rakista80](https://forum.codewithmosh.com/u/rakista80)\
**Post date:** [September 14, 2022, 1:03pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/1 "2022-09-14T13:03:34Z")

</div>

Hello guys,  
I am having this error for 2 days now and I can’t find a solution online. Maybe someone who already find a solution for this, please help. Thanks in advance.

./src/main.ts - Error: Module build failed (from ./node\_modules/@ngtools/webpack/src/ivy/index.js):  
Error: Emit

./src/polyfills.ts - Error: Module build failed (from ./node\_modules/@ngtools/webpack/src/ivy/index.js):  
Error: Emit

Error: Failed to initialize Angular compilation - Cannot read properties of null (reading ‘fileName’)

\*\* Angular Live Development Server is listening on localhost:4200, open your browser on [http://localhost:4200/](http://localhost:4200/) \*\*

× Failed to compile.

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [September 14, 2022, 2:17pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/2 "2022-09-14T14:17:56Z")

</div>

Looks like something wonky with the node modules. Try:

1. delete the node\_modules folder
2. delete package-lock.json
3. clear your NPM cache: `npm cache clean --force`
4. install again all dependencies: `npm i`

Otherwise this may have to be reported to the `@ngtools` owners by opening a GitHub issue here: [Issues · angular/angular-cli · GitHub](https://github.com/angular/angular-cli/issues)

---

<div class="post-metadata">

**Author:** ![rakista80](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rakista80](https://forum.codewithmosh.com/u/rakista80)\
**Post date:** [September 15, 2022, 6:43am UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/3 "2022-09-15T06:43:04Z")

</div>

Thanks for your response. I tried and follow the steps and now node\_modules turned grey as if they are not part of the project.

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [September 15, 2022, 1:07pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/4 "2022-09-15T13:07:16Z")

</div>

Did you run the commands from inside your project folder?

---

<div class="post-metadata">

**Author:** ![rakista80](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rakista80](https://forum.codewithmosh.com/u/rakista80)\
**Post date:** [September 15, 2022, 1:19pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/5 "2022-09-15T13:19:05Z")

</div>

Yes, both inside and outside the project folder.

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [September 15, 2022, 1:26pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/6 "2022-09-15T13:26:52Z")

</div>

Does your project build? Is the node\_modules folder empty after reinstalling dependencies?

---

<div class="post-metadata">

**Author:** ![rakista80](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rakista80](https://forum.codewithmosh.com/u/rakista80)\
**Post date:** [September 15, 2022, 1:34pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/7 "2022-09-15T13:34:10Z")

</div>

The project did not build and the node\_modules folder not empty after reinstalling dependncies but it’s greyed out on mac as if its not activated but for windows its shows normal but again same error is there. It all starts when I add service for a contact form to be save in firebase. If in case I want to remove the services all will be working fine.

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [September 15, 2022, 2:19pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/8 "2022-09-15T14:19:50Z")

</div>

Sorry - I do not have any other advice (other than maybe try “turning it off and on again” on your Mac). As I said, you might try reporting the issue on GitHub so that the owners of ngtools can respond.

---

<div class="post-metadata">

**Author:** ![wosh1ngton](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@wosh1ngton](https://forum.codewithmosh.com/u/wosh1ngton)\
**Post date:** [September 16, 2022, 1:12pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/9 "2022-09-16T13:12:08Z")

</div>

Same problem here, it happened to me after I’ve installed ng2-toast and include it in the imports array, inside the app.module.

here are the messages:

./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.

Error: Failed to initialize Angular compilation - Importing unexpected symbol ɵɵinvalidFactory while compiling @angular/core

since then, I’ve tried update the @angular/core and @angular/cli,  
I’ve tried an older version of toasty,  
unfortunatelly, without success.

---

<div class="post-metadata">

**Author:** ![shereen](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@shereen](https://forum.codewithmosh.com/u/shereen)\
**Post date:** [March 29, 2023, 7:59am UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/10 "2023-03-29T07:59:38Z")

</div>

I have the same error,  
were you solve this problem?

---

<div class="post-metadata">

**Author:** ![romerobrjp](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@romerobrjp](https://forum.codewithmosh.com/u/romerobrjp)\
**Post date:** [November 4, 2024, 5:45pm UTC](https://forum.codewithmosh.com/t/error-module-build-failed-from-node-modules-ngtools-webpack-src-ivy-index-js/15154/11 "2024-11-04T17:45:45Z")

</div>

Hi guys,

I’m facing a similar issue related to @ngtools in my Angular 18 project.

```auto
./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i6.MercerOSModule to symbol

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i6.MercerOSModule to symbol

```

Are there any updates about that?
