The Grouparoo Blog


Node.js Memory Error on Mac Using M1

Tagged in Notes 
By Sean C Davis on 2021-02-08

I was working with our fancy new CLI tool with my fancy new MacBook Pro with the M1 chip when I came across this scary error, courtesy of Node.js:

FATAL ERROR: wasm code commit Allocation failed - process out of memory

It began occurring regularly enough that I started digging. I've since come across two methods for solving this issue.

Method #1: Upgrade to Node v15

I found this discussion which noted that Node.js versions prior to v15 do not natively support the Apple M1 chip. (At least not yet.)

Our team uses NVM (Node Version Manager) to install and manage multiple node versions. I happened to be working with v12.

$ nvm ls
->     v12.20.1
        system
default -> 12 (-> v12.20.1)
...

So I gave v15 a shot.

$ nvm install 15
$ nvm use 15
$ nvm alias default 15

Voila! It seemed to do the trick. I even tried v14 just to see what would happen, and sure enough, I also ran into issues with it.

I still run into intermittent issues with v15, so I don't feel like this is a foolproof solution. But it's a quick path to try.

Method #2: Run in Compatibility Mode

Another option is to run your terminal in compatibility mode using Rosetta. Rosetta is a environment that translates executables to be able to run on the Apple M1 chip. It's build specifically to ease the transition to Apple's new chip.

To run your terminal application in compatibility mode, set it to Open using Rosetta, then reinstall node versions. See here for more info.

After going down this route, it's felt safer. But, starting the process was opening a can of worms. It wasn't just a matter of open Terminal differently and reinstalling Node. Because Node relies on other libraries, I also needed the appropriate versions of those libraries, too. But Homebrew updated for the new chip and now installs libraries in a different location.

It became a whole thing and, because I had just opened my computer, I ended up wiping it and starting clean. I'm confident I would have eventually gotten to a working situation using Rosetta. Starting over just felt like a simpler path for me with a new machine.

My advice to you is to start with the first method and see how far it gets you. If it doesn't solve the problem, then move on to this second method, but be prepared to go down a rabbit hole in the process!




Get Started with Grouparoo

Start syncing your data with Grouparoo Cloud

Start Free Trial

Or download and try our open source Community edition.