Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular build fails with malloc error on second build #36

Open
YukiFujisawa opened this issue Dec 15, 2024 · 0 comments
Open

Angular build fails with malloc error on second build #36

YukiFujisawa opened this issue Dec 15, 2024 · 0 comments

Comments

@YukiFujisawa
Copy link

Angular build fails with malloc error on second build

Description

When running the Angular build command twice in succession, the second build fails with a malloc error. The first build completes successfully, but subsequent builds fail with a memory-related error.

Environment

Angular CLI: 19.0.5
Node: 20.18.1
Package Manager: npm 10.8.2
OS: darwin arm64

Angular: 19.0.4
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1900.5
@angular-devkit/build-angular   19.0.5
@angular-devkit/core           19.0.5
@angular-devkit/schematics     19.0.5
@angular/cdk                   19.0.3
@angular/cli                   19.0.5
@angular/material              19.0.3
@schematics/angular           19.0.5
rxjs                          7.8.1
typescript                    5.6.3
zone.js                       0.15.0

Error Message

node(71866,0x20647cf40) malloc: *** error for object 0x3bb90e420460: pointer being freed was not allocated
node(71866,0x20647cf40) malloc: *** set a breakpoint in malloc_error_break to debug
sh: line 1: 71816 Abort trap: 6           npm run build-ui

Steps to Reproduce

  1. Run first build command: npm run deploy
    • Result: Build succeeds
  2. Run second build command: npm run deploy
    • Result: Build fails with malloc error

Proposed Solutions

Solution 1: Clear Angular CLI Cache

Running ng cache clean resolves the issue.

Solution 2: Add Clean Step to Build Process

Adding a clean step to the build-ui script in package.json:

{
  "scripts": {
    "build-ui": "npm run clean --prefix src/ui && npm run build --prefix src/ui"
  }
}

Additional Context

The error appears to be related to Angular CLI's cache management. Either clearing the cache manually or implementing an automatic clean step before builds prevents the malloc error from occurring.

Questions

  • Are these solutions effective for all environments and Angular versions?
  • Is there a more fundamental solution that addresses the root cause of the malloc error?
  • Could this be related to a specific version of the Angular CLI or Node.js?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant