Ga naar inhoud

Apple Silicon (M1/M2/M3) Macs

Overview

Apple Silicon Macs use ARM architecture instead of Intel's x86_64. This guide covers compatibility issues and solutions for development on M1/M2/M3 Macs.


Node Version Manager

Running Older Node Versions

If an older Node version won't run natively, you can run Node via the x86 emulator (Rosetta 2).

# Uninstall the ARM version
nvm uninstall 10

# Switch to x86_64 architecture
arch -x86_64 zsh

# Install Node under x86 emulation
nvm install 10

Reference: Stack Overflow solution


Checking ARM Compatibility

Does It ARM?

Wondering if a program or dependency is compatible with Apple Silicon?

Use doesitarm.com - a community-maintained database tracking which apps and dependencies work on Apple M1/M2/M3 ARM processors.


Homebrew

Installing Packages with Rosetta 2

If you encounter this error:

Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!

This package doesn't work via the Rosetta 2 installer. Switch back to ARM architecture:

arch -arm64 brew install PACKAGE_NAME

Homebrew Architecture Paths

  • ARM (Apple Silicon): /opt/homebrew/
  • x86 (Intel/Rosetta): /usr/local/homebrew/

Docker

Running Containers for Different Platforms

To run a Docker container as a different platform (e.g., AMD64/x86):

docker run --platform linux/amd64 node

This is useful when: - Container images aren't available for ARM - You need to test cross-platform compatibility - Dependencies require x86 architecture


Python 2

Installing Python 2 on Apple Silicon

Python 2 is officially no longer supported by Homebrew.

If you need Python 2 to build legacy projects:

  1. Download the installer from the official website
  2. Install the most recent version (2.7.18)

Note: Consider migrating to Python 3 whenever possible, as Python 2 reached end-of-life in 2020.


Common Issues and Solutions

Native vs Emulated Performance

  • Native ARM: Best performance, use when possible
  • Rosetta 2 (x86 emulation): Slower, but good compatibility
  • Check architecture: uname -m (arm64 = native, x86_64 = emulated)

Terminal Architecture

Check which architecture your terminal is running:

uname -m

Output: - arm64 - Native Apple Silicon - x86_64 - Running under Rosetta 2

Switching Terminal Architecture

Open a new shell in different architecture:

# Switch to x86_64 (Rosetta 2)
arch -x86_64 zsh

# Switch to ARM
arch -arm64 zsh

Compiling Native Gems (Ruby)

If Ruby gems fail to compile:

# Install with native architecture
arch -arm64 gem install gem_name

# For Bundler
arch -arm64 bundle install

Resources


See Also