Command failed with exit code 137

Hi team, I am getting following error for my site while building build.I’m running the same command on my local and I don’t encounter the same issue. My sites info and error logs are as following:

  • netlify site name: plenty-network-temp-development

  • deploy link: Netlify App

  • Build logs(error):

3:29:38 PM: info - Generating static pages (3/12)
3:29:40 PM: Killed
3:29:40 PM: ​
3:29:40 PM: “build.command” failed
3:29:40 PM: ────────────────────────────────────────────────────────────────
3:29:40 PM: ​
3:29:40 PM: Error message
3:29:40 PM: Command failed with exit code 137: CI=false npm run build (Search results for '"non-zero exit code: 137"' - Netlify Support Forums)
3:29:40 PM: ​
3:29:40 PM: Error location
3:29:40 PM: In Build command from Netlify app:
3:29:40 PM: CI=false npm run build
3:29:40 PM: ​
3:29:40 PM: Resolved config
3:29:40 PM: build:
3:29:40 PM: command: CI=false npm run build
3:29:40 PM: commandOrigin: ui
3:29:40 PM: environment:
3:29:40 PM: - CI
3:29:40 PM: - NEXT_PUBLIC_RPC_MAINNET
3:29:40 PM: - NEXT_PUBLIC_RPC_TESTNET
3:29:40 PM: - NEXT_PUBLIC_TZKT_GHOSTNET
3:29:40 PM: - NEXT_PUBLIC_TZKT_MAINNET
3:29:40 PM: - NODE_OPTIONS
3:29:40 PM: - REVIEW_ID
3:29:40 PM: - NEXT_PRIVATE_TARGET
3:29:40 PM: publish: /opt/build/repo/.next
3:29:40 PM: publishOrigin: ui
3:29:40 PM: plugins:
3:29:40 PM: - inputs: {}
3:29:40 PM: origin: ui
3:29:40 PM: package: ‘@netlify/plugin-nextjs’
3:29:42 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
3:29:42 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:29:42 PM: Failing build: Failed to build site
3:29:42 PM: Finished processing build request in 1m48.307s

My site is using nextjs.

Thank you.

@kapiltez Error 137 is likely to be a memory issue.

See:

How can I know if memory getting full or is there any issue? Can you help me with proper debugging?

If it’s memory issue, how can I fix in my case for nextjs app?

@kapiltez Did you read the support guide that I linked to?

yes tried with increasing momory size in env var as well. Since my app is in nextjs, shall I use gatsby as suggested in above blog?

@kapiltez No, I think you’ve misunderstood that support guide.

The guide says that Gatsby is one of the build systems that most encounters memory issues.

It provides suggestions for how to increase the memory (which can only be increased so far), or to reduce your usage.

If you think you are hitting a memory issue you should optimize your build… change it so that it uses less memory.

on vercel it’s perfectly fine. Isn’t there any other way to increase the memory?

@kapiltez I couldn’t say, as I work exclusively with my own static site generator and I’ve never run into a memory issue.

You could try googling around, or wait and see if Netlify’s support crew have any information to add.

hi @kapiltez

I’ve replied to your helpdesk thread as well.

TLDR: some builds for that same context (a deploy preview for PR#993 against your prod branch) are failing since you’re doing something resource heavy.

Your production builds are not failing due to memory, what changed on this particular PR?

Thanks!

sure thing. A couple of stuffs got updated in code.