TLDR

  • NPM isn’t compiled for ARM by default for versions before 15
  • You will need to install older versions of NPM under Rosetta 2

Problem

  • One of the designers in the team was trying to run an old prototype built using npm 8
  • She was using a M1 MacBook Pro
  • Trying to run the project wasn’t working for her and it was throwing all sorts of errors

Example error output

$ nvm install 8.9.1
Downloading and installing node v8.9.1...
Downloading https://nodejs.org/dist/v8.9.1/node-v8.9.1-darwin-arm64.tar.xz...
#=#=-#                                                                            
curl: (22) The requested URL returned error: 404 
Binary download from https://nodejs.org/dist/v8.9.1/node-v8.9.1-darwin-arm64.tar.xz failed, trying source.
...............
... more output
...............
nvm: install v8.9.1 failed!

Solution

In your shell:

# Switch the processor architecture to emulate the old Intel chips
arch -x86_64 zsh

# Install whatever version of the node binaries you need
nvm install 8.9.1 

Further Reading