Installing Node 12 on Apple Silicon
While attempting to start work on a legacy Vue2 app, I ran into an issue I've never had before. I was unable to install the correct Node version required by the project (Node v12). Upon attempting the install via NVM, I would just get this vague error.
make: *** [node] Error 2
For some more context, I am working off of a branch new M4 Mac. With that, I assumed it could very well be something to do with the Apple vs Intel chip. Turns out, that was exactly it. Why? Node did not start creating binaries compatible with Apple chips (darwin-arm64) until Node v16. NVM attempts to build these older versions from source when binaries aren’t found for a given OS/architecture.
After some research I found this this could have been easily solved using a Rosetta shell but I decided to take the more complicated path and spin up a Docker container. We eventually want this project to be dockerized anyway so this felt like a great first step.
For anyone who does not want to do that however, here is the simpler, Rosetta solution
- Start Rosetta shell (assuming you're using zsh)
# Start a Rosetta shell (Intel emulation mode)
arch -x86_64 zsh- Verify you're running under the Intel emulation
# Should return x86_64
uname -m- Proceed to install older Node version
nvm install 12