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

NextJS build always going out of heap memory when building #76704

Open
Falling12 opened this issue Mar 1, 2025 · 4 comments
Open

NextJS build always going out of heap memory when building #76704

Falling12 opened this issue Mar 1, 2025 · 4 comments

Comments

@Falling12
Copy link

Link to the code that reproduces this issue

https://github.com/Falling12/loyalty-backend

To Reproduce

  1. Download the repo
  2. Start a build
  3. Watch the app go out of memory, I also tried giving more memory to nodejs, but 8 gigs wasnt enough too

Current vs. Expected behavior

Whats happening:

  1. The app is building normally until this step: ✓ Generating static pages (18/18)
  2. Then its starting to fill the memory
  3. And then I got the issue: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Excepted behavior:
The app should build normally

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8122
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 9.15.4
Relevant Packages:
  next: 15.1.7 // There is a newer version (15.2.0) available, upgrade recommended! 
  eslint-config-next: 15.1.7
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

I'm developing this not really large app for a restaurant but recently got this issue where I can't build the app. It can happen that my code is wrong somewhere but I don't really think this. I would be pleased if someone could look into my code aswell. (The build also failed with the same issue when deploying to Vercel)

Thank you for the help in advance!

@sinan2000
Copy link

I would advise you firstly to cancel that service account, delete from your repo and add to .gitignore so you can make a new one. Anyone can have access to your firestore, firebase auth or any kind of firebase service that you have right now for this project.

@Falling12
Copy link
Author

I would advise you firstly to cancel that service account, delete from your repo and add to .gitignore so you can make a new one. Anyone can have access to your firestore, firebase auth or any kind of firebase service that you have right now for this project.

Yeah, I know, but thats not a production environment. But I wall add it to gitignore. Thank you!

@ericmesmo

This comment has been minimized.

@Falling12
Copy link
Author

Did u find any solution?

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!

Yes, I actually found a workaround, if you add the following experimental feature to the config it will use less RAM.

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
experimental: {
esmExternals: false
},
};

export default nextConfig;

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

3 participants