angular: Node runs out of memory running our builds

I’ve seen it crash on JS bundle tasks and build/pure-packages.dart. @hterkelsen reports it crashing on JS sourcemaps.

Workaround: node --max-old-space-size=2000 ./node_modules/.bin/gulp {TASK}

(2000 is 2GB)

  • fix the underlying issue
  • remove the heap config workaround from scripts/publish/npm_publish.sh

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 24 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Why not allocate more memory to the entire gulp process, rather than start a sub-process? Is it to avoid parts of the build outside of bundling that start to rely on more available heap?

One solution is to use npm run-scripts in the package.json so the memory settings are saved with the gulp command to run, eg

"scripts": {
  "build": "node --max-old-space-size=2048 ./node_modules/.bin/gulp build.js"
}

(I’m trying this now because I have the same issue on Circle, which already uses npm run build rather than shell scripts as the build step)

on windows environment I needed:

"scripts": {
  "build": "node --max-old-space-size=2048 node_modules/gulp/bin/gulp.js"
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

run as usual:

npm run build