2

My goal is to install node version 8 so I can run Gulp on a project.

I'm working on an old project that has been neglected and passed downed to me by another developer. I'm told I can work with Gulp by installing Node Version 8 and declaring the node version in my package.json file.

But whenever I try to run nvm install 8I receive the error error: "unsupported ARM architecture"

My system is MacOS Big Sur M1 Chip

I am not too sure what I'm supposed to do here. Please help!

Roundy
  • 121
  • 1
  • 8

2 Answers2

9

Solution

The solution was to change the architecture of my shell from arm64 to x86.

Macs with M1 chip

January 2021: there are no pre-compiled NodeJS binaries for versions prior to 15.x for Apple's new M1 chip (arm64 architecture).

Some issues you may encounter:

  1. using nvm to install, say, v14.15.4:
  • the C code compiles successfully
  • but crashes with an out of memory error when used
  • increasing the memory available to node still produces the out of memory errors: $ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/your_node_package
  1. when using nvm to install some versions, the compilation fails

One solution to this issue is to change the architecture of your shell from arm64 to x86.

Let's assume that:

  • you already have versions 12.20.1 and 14.15.4 installed using nvm
  • the current version in use is 14.15.4
  • you are using the zsh shell
  • you have Rosetta 2 installed (macOS prompts you to install Rosetta 2 the first time you open a Intel-only non-command-line application, or you may install Rosetta 2 from the command line with softwareupdate --install-rosetta)
//# Check what version you're running:
$ node --version
v14.15.4
//# Check architecture of the `node` binary:
$ node -p process.arch
arm64
//# This confirms that the arch is for the M1 chip, which is causing the problems.
//# So we need to uninstall it.
//# We can't uninstall the version we are currently using, so switch to another version:
$ nvm install v12.20.1
//# Now uninstall the version we want to replace:
$ nvm uninstall v14.15.4
//# Launch a new zsh process under the 64-bit X86 architecture:
$ arch -x86_64 zsh
//# 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
//# And the new version is now available to use:
$ nvm use v14.15.4
Now using node v14.15.4 (npm v6.14.10)

source: https://github.com/nvm-sh/nvm

Roundy
  • 121
  • 1
  • 8
  • 1
    When running 'arch -x86_64 zsh' I received the error 'arch: posix_spawnp: zsh: Bad CPU type in executable'. However, you can workaround this by finding the terminal/iterm app, right click and select 'Get info', and enable the option 'Open using rosetta'. Restart the terminal and it will start with the x86 architecture. After completing the installation steps with nvm, go back and uncheck the rosetta option and restart terminal. – maxorcist Apr 08 '22 at 11:31
2
  • Find UR iTerm (or any other termial ur using)

  • Double-click =>【get info】

  • In General Panel:
    ✅ Open using Rosetta (selected this item)

  • Back to termial and continue use nvm install 8

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 31 '21 at 18:03
  • Clarification for step #1. "Using finder, navigate to the install location of your terminal" – Doctor Parameter Feb 22 '23 at 17:19