huge memory use on build?
See original GitHub issueThe build process of my next.js application seems to use an unusual amount of memory causing the following error when attempting to deploy with now:
> Deploying ~/web/PWA under xxxx@gmail.com
> Using Node.js 8.9.3 (default)
> Ready! https://formulastocks-kixfvvuhaf.now.sh (copied to clipboard) [13s]
> Synced 15 files (27.62KB) [0ms]
> Initializing…
> Building
> â–˛ npm install
> âś“ Using "package-lock.json"
> ⧗ Installing 57 main dependencies…
> âś“ Installed 1295 modules [10s]
> â–˛ npm run build
> > FormulaStocks@1.0.0 build /home/nowuser/src
> > next build
> > Using external babel configuration
> > Location: "/home/nowuser/src/.babelrc"
> > Using "webpack" config function defined in next.config.js.
> npm ERR! code ELIFECYCLE
> npm ERR! errno 137
> npm ERR! FormulaStocks@1.0.0 build: `next build`
> npm ERR! Exit status 137
> npm ERR!
> npm ERR! Failed at the FormulaStocks@1.0.0 build script.
> npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
> npm ERR! A complete log of this run can be found in:
> npm ERR! /home/nowuser/.npm/_logs/2018-01-03T10_55_16_097Z-debug.log
> Error! The build step of your project failed. To retry, run `now --force`.
This was identified in #3407 to be due to the app using way too much memory in the build process and the OSS version of now only allowing 500MB of memory.
Before it was using 1.3GB of memory (when testing the build process locally, as I can’t actually see how much it is on now).
I then tried to move ALL of the non-page files out of the pages folder and into the components folder as I was recommended by @timneutkens and I got the build process down to around 700MB.
However, that’s still unusually high for just 12 routes?
Why does it use so much memory, and any ideas how to reduce this to an acceptable amount? I will need to add more routes in as well, and if it’s already at 700MB even the paid version won’t work for me.
Link to failing build: https://formulastocks-kixfvvuhaf.now.sh
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Related StackOverflow Question
I also tried removing my _document file, to see if that was causing something that required a lot of memory on all pages. But that didn’t work either…
Any ideas at all what might be causing this!?
Most of the memory use is coming from webpack compiling pages. There’s not that much we can do to optimize it unfortunately. Going to close this as this is on our list of things to tackle 👍