Want to use Node on your fancy new MacBook with an M1 (aka Apple Silicon, aka ARM) processor? Sure you do. While macOS Big Sur supports x86 emulation via Rosetta 2, let’s run native arm64 binaries for maximum speed and minimum power consumption.
Step 1: Install arm64 Homebrew
Open a Terminal and veryify you are not in x86 emulation mode:
arch
You should see arm64
.
Now, we’re going to follow homebrew’s recommendation and install homebrew to /opt/homebrew
. Below are the commands to create that folder, set the perms of that folder, then install homebrew and add it to your path.
cd /opt
sudo mkdir homebrew
sudo chown -R $(whoami) homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
If you don’t use zsh as your shell then adjust that last command accordingly
Now either open a new terminal with your updated .zshrc
or source it (source ~/.zshrc
) so you can run the brew
command from anywhere in your terminal.
Step 2: Install Node via Homebrew
This is the easy part… since our homebrew install is arm64 any bottles installed from it are also arm64. So to install the arm64 version of node just run:
brew install node
That’s it, happy dev’ing on ARM!
Hopefully you found this post helpful, if you have any questions you can find me on Twitter.