64

I'm trying to install the latest version of node using nvm. I've just got the newly released SIlicon Macbook Pro with the M1 chip (not sure if that is related). I've installed xcode on the app store and the xcode tools on the command line. The main error i'm getting is:

clang: error: no such file or directory: 'CXX=c++'
1
  • and they don't even have documentation for it anywhere. Commented Jul 7, 2023 at 12:17

9 Answers 9

196

If you have installed nvm using homebrew and are trying to install the node using command nvm install <some_version>, you will face errors on apple silicon machines (ARM) for versions lower than 15. Node versions older than 15 do not work on apple silicon machines (ARM) because ARM architecture is not supported. For anything under v15, you will need to install node using Rosetta 2.

  1. How to open terminal in Rosetta2 mode: Go to Application -> Right click on terminal app -> Get Info -> Select "Open using Rosetta" -> Restart Terminal
  2. In Terminal, write -> arch -x86_64 zsh

Now you will able to install any version of node (even multiple versions)

Sign up to request clarification or add additional context in comments.

13 Comments

(nvm maintainer here) note that nvm is explicitly not supported when installed via homebrew - the only correct way to install it is with the install script in nvm's readme.
I am getting arch: posix_spawnp: zsh: Bad CPU type in executable
I installed via the nvm install script and ran into the same error -- and the steps by @adityaatri to run Terminal or iTerm2 in Rosetta mode also worked for me.
I first needed to install Rosetta. This was all I did, WITHOUT opening the terminal using right click etc. 1. install nvm via the script at the github repo (not homebrew) 2. softwareupdate --install-rosetta 3. arch -x86_64 zsh 4. nvm install 14.8.0
Step 1 was optional for me, Step 2 did the trick for me
|
38

it wasn't an issue while i was trying to install node 12.X.X but below that it was a big pain so i followed below steps and it worked for me

Uninstalled nvm if it’s already installed using Homebrew.

brew uninstall nvm
brew cleanup

Install Rosetta

softwareupdate --install-rosetta

Make terminal/iTerm2 to open in Rosetta mode

got to Application (-> utilities) -> right click on terminal app -> get Info -> Select "Open using Rosetta" -> Restart Terminal

In Terminal run a command

arch -x86_64 zsh 

Make sure machine has .zshrc file if not just create one

cd ~
touch .zshrc

Install NVM

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

Restart the terminal and check if nvm is installed successfully by running

nvm -v

Then install Node with nvm as usual

nvm install 10

2 Comments

Works for me on Mac Pro M3!
for me, the curl command gives output nvm is already installed in /Users/robertd/.nvm, trying to update using git and bash_completion source string already in /Users/robertd/.zshrc . Therefore it seems unclear whether brew uninstall nvm and brew cleanup actually clean up everything.
31

In 2023, this is quite simple. Install nvm in the normal way without using Rosetta.

Then install Rosetta which you can install by running in the macOS Terminal:

softwareupdate --install-rosetta

Once installed, run

arch -x86_64 zsh

then if you want to install say 12

nvm install lts/dubnium

It will install, you can then use

nvm use 12

whenever you want to use 12, you don't have to do anything special to run it from here, it works without using arch -x86_64 zsh

Hope that helps!

3 Comments

Mar 2024 and this doesn't work with Node v14.21.3
Worked for me with v14.19.0
Jul 2025 and this worked for me with v14.17.6
4

Follow these steps if you have M1/M2 and you have installed nvm via homebrew

rm -rf ~/.nvm
rm -rf ~/.npm
rm -rf ~/.bower

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

Comments

1

If you are trying to install nvm 14 and If the output is arm64, you'll need to switch your architecture to x86_64 temporarily during the installation. Here are steps to resolve the issue:

  1. Install Rosetta 2 (if not already installed): softwareupdate --install-rosetta --agree-to-license
  2. Temporarily open a terminal with x86_64 architecture: arch -x86_64 /usr/bin/env bash
  3. Install Node.js 14.21.3: nvm install 14.21.3
  4. Verify the installation: node -v
  5. Exit the x86_64 shell: exit

1 Comment

great, thanks! i needed to init nvm before step 3
0

I did the following:

Run software update: softwareupdate --install-rosetta --agree-to-license

Error in Rosetta Updater, but you can: grep RosettaUpdateAuto.pkg /var/log/install.log

and just: open /path/to/RosettaUpdateAuto.pkg

After that, right-click your terminal icon in dock > Open > Options > Show in Finder.

Then, right-click > Get Info.

Then, check 'Open using Rosetta'

In the terminal you can check you are using rosetta with: arch

Then just: nvm install v6.9.1 # for example

Comments

0

From @milomg in this GitHub issue page:

If you're looking for a precompiled link, you might find https://nodejs.raccoon-tw.dev/ useful

NVM_NODEJS_ORG_MIRROR=https://nodejs.raccoon-tw.dev/release nvm install v14.21.3

Comments

-1

Install nvm version > 0.3.7 and install node version >= 16.0

Comments

-1

Use the following command for successful install:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

before the above command, please be sure to have .zshrc file in the root of your current username folder (~/).

1 Comment

This is to install nvm, not how to install a version of node using nvm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.