23

I'm working with angular 14 and node 16 and typescript. I was working normally, but now when i execute the ng serve command, i get the following error:

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Maximum call stack size exceeded

here is my ng version

enter image description here

3
  • 1
    Maybe you have some files that have circular dependencies (import/export) Commented Aug 1, 2022 at 17:04
  • Yes, i check it out and yes it was Commented Aug 3, 2022 at 12:50
  • I had this problem when a module was accidentally importing itself. Commented Apr 2, 2023 at 20:58

4 Answers 4

38

check the modules import , you may have circular importation

Sign up to request clarification or add additional context in comments.

2 Comments

Seems like it only bothers me, that in Angular the error description is not related to the real reason.
Got AppModule imported in one of the child modules after generating component in Intellij IDEA.
22

I got this error, as I stupidly included a package in both declarations and imports in my app.module.ts file:

@NgModule({
  declarations: [
    CanvasJSChart,
    . . .
  ],
  imports: [
    CanvasJSChart,
    . . .

Moral of the story: don't drink and code.

2 Comments

Had a similar issue, I was mistakenly importing the same module itself, instead of another module with a similar name
Or...and stay with me here...drink more and code.
7

Please check module routing carefully. You may have declared same component both in declarations and imports.

play it in this way....

@NgModule({
  declarations: [
    FooterComponent,
    NavbarComponent
  ],
  imports: [
    CommonModule,
  ],
  exports:[
    FooterComponent,
    NavbarComponent
  ]
})

Comments

0
rm -rf node_modules
npm install

2 Comments

it will be helpful if you explain what the first command do
@DoryDaniel It removes the node_modules and content inside including nested folders. rm: Stands for "remove". This command is used to delete files and directories. -r: Stands for "recursive". This option tells rm to delete directories and their contents recursively. Without this option, rm would not delete directories unless they are empty. -f: Stands for "force". This option overrides any confirmation prompts and suppresses error messages, making the deletion operation non-interactive and more aggressive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.