macOS Big Sur: How to setup Node.js on Apple M1 Machine

Recently I bought an Apple's M1 Macbook Pro. As I am still transitioning from my old MacBook, it might be helpful to document some findings from the developer perspective, especially for developers working with javascript stuff on a daily basis like me.

So far, the transitions are pretty smooth, and many developer tools have also been updating their latest versions to work natively with the M1 machine (yes, including docker).

If you are installing Node.js, I recommend using Node Version Manager (nvm) over Homebrew. It's similar to RVM (Ruby Version Manager) for Ruby language that allows you to switch between Node versions, which is essential easily.

Install

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Install the latest version.

$ nvm install node

Restart terminal and run the final command.

$ nvm use node

Confirm that you are using the latest version of Node and npm.

> node -v && npm -v

Switch Architecture

First, confirm that you are on arm64

$ node -p process.arch
arm64

Sometimes you still need to work on x64 architecture. Most likely because some of the libraries or npm packages that you are using are not working natively with M1 yet.

Switch to x64 architecture environment.

$ arch -x86_64 zsh

check that the architecture is correct.

$ node -p process.arch
x64

Install node using nvm. This should download the precompiled x64 binary:

$ nvm install v14.15.4

Now, check that the architecture is correct:

$ node -p process.arch
x64

It is now safe to return to the arm64 zsh process:

$ exit

We're back to a native shell:

$ arch
arm64

Create a Rosetta Terminal

You can also set the Open using Rosetta option on Terminal.app or iTerm.app until more stuff works with arch64 and the toolchain on the M1 macs (most if not all of this stuff already works, though).

  1. Right click the app (Terminal, iTerm, etc.)
  2. Tap "Get Info"
  3. Select "Open using Rosetta"
  4. Restart terminal
run iIterm on Rosetta

But I'd prefer the former way, because by using arch -x86_64 zsh you can use Rosetta on a need to use base and not need to run the whole terminal in Rosetta mode.

Finding and installing native applications

Right now, there are still a few applications that don't offer full native support for Apple Silicon. So we have to install the x86_64 versions of these applications. This means that Rosetta will run in the background to translate the application and make it compatible to run on the M1, but this also means that it will not run fully ARM optimized.

You can visit the website “Does it ARM?” or Is Apple silicon ready? and search for any app. It’s a great resource to find and install Apple Silicon versions of your apps.

That's it. I hope it helped speed up your process of developing apps on your Apple Silicon Macs.

Stay up to date

Get notified when I publish something new, and unsubscribe at any time.