Problems with setting up Layer5 for development

If you’re a first time contributor, you may face some issues while setting up a local build of the layer5io/layer5 repository.

I faced some challenges myself, so I’m writing to a post to share what I’ve learnt.

I’m running Ubuntu 24.04 with 16GB RAM, and the build is running directly on my OS (not virtualized).

Before moving forward, let’s review the setup commands:

  • make setup - this command installs all the necessary dependencies from Layer5
  • make site - this starts a local development server with hot-reloading, GraphQL debugging, and automatic rebuilds for live testing.

What’s happening?

When you run make site, the build process often runs out of heap memory, leading to either a process kill or a complete crash.

The terminal output for the same is:

success Building development bundle - 32.041s
success onPreExtractQueries - 0.004s
success extract queries from components - 1.415s
success write out requires - 0.006s
success Re-building development bundle - 2.497s
Killed
make: *** [Makefile:26: site] Error 137

You may also notice your machine suddenly turning slow or unresponsive.

Solution

One way to mitigate this issue is to use the NODE_OPTIONS command, and manually allocate some RAM to the process. Example,

NODE_OPTIONS="--max-old-space-size=<RAM-in-MB>" npx gatsby develop
NODE_OPTIONS="--max-old-space-size=8192" make site

This prevents crashes by ensuring Node.js has enough memory during the build.

Disabling auto-save on your code editor, and saving only after making the necessary changes is also one way to avoid system crashes.

Has anyone else faced this issue? This is one way to fix to the ran out of memory
problem.

I hope this helped :slight_smile:

1 Like

Please let me know if there are any other potential solutions apart from manually allocating memory via NODE_OPTIONS.

Great post, @M-DEV-1! Here’s a tip offered by Gatsbyjs:

Try reducing the number of cores

Gatsby defaults to using the number of physical cores on your machine to speed up builds, and parallelizes during certain steps of the process (image processing, Javascript bundle creation, and HTML generation).

So if you’re experiencing out of memory issues during any of those steps, you can try setting the environment variable GATSBY_CPU_COUNT to a lower number, like 2. Note that this will slow your builds down!

1 Like

Thank you for the solution!

I tried setting GATSBY_CPU_COUNT=4 locally while running make site, and while it did cause a spike in memory usage, it didn’t exhaust my system or kill the process.

I’ll continue contributing while experimenting with the count variable.

1 Like