Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install NodeJS natively on Apple Silicon M1?

I am trying to install NodeJS on the new Apple Silicon MacBook Pro, but I wasn't able to find a way to install it on the ARM-based Apple M1.

The standard installation will run in Intel emulation mode, but I saw they already have an ARM Linux version which I assume is not suitable for M1 Macs.

If possible, how can I install Node.JS on Apple Silicon without having it run in emulation mode?

like image 518
Lucki Avatar asked Nov 18 '20 19:11

Lucki


People also ask

Is NodeJS available for M1 Mac?

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.

Does NodeJS support Apple Silicon?

Node. js 16 was released on April 20, adding Apple Silicon binaries and additional stable APIs to the popular JavaScript runtime. The release is the first to ship with prebuilt binaries for Apple Silicon. While Node.

Does Homebrew work on M1 Mac?

If you're coming to M1 Mac fresh, without any old projects or profiles, you probably won't notice; Homebrew will work as it always has. But if you're trying to migrate from an Intel Mac you won't be able to just move packages that were once in /usr/local over to /opt/homebrew .


2 Answers

The primary Node.JS repository has Issue #2747, which was updated yesterday with a note that current versions of Node compile just fine with no modifications required via Rosetta 2. The same post indicated that there was still in-flight "work to be done" to compile Node to an M1-native binary to unlock additional performance benefits.


Additional resources:

  • Node.JS Technical Steering Committee opened Issue #886 in their GitHub repository to track Node's support for Apple Silicon.
like image 60
esqew Avatar answered Oct 18 '22 21:10

esqew


Hit similar issues. I would recommend you enable "Open using Rosetta" on Terminal, which should reduce all ends of pain for the moment. When this was enabled, I was able to install Node, as well as Homebrew, etc, with no issues. To do to:

  1. right click your terminal app from Finder
  2. select "Get Info"
  3. enable "Open using Rosetta"

N.B. I am using iTerm in the screenshot below, but the same applies for Terminal

Enabling Open using Rosetta

like image 28
richardbarbour Avatar answered Oct 18 '22 20:10

richardbarbour