JustAProgrammer
JustAProgrammer

Reputation: 749

zsh: bad CPU type in executable: node

I have installed nvm using brew. After that, I installed node version of 16 through nvm and check the current version using node -v to see whether the node is working properly. However, when I install version 14 or any other previous versions and runs node -v, it gives this "zsh: bad CPU type in executable: node" message and I have no idea what to do about this, though, installing node v17 and running node -v works as expected. Below are the snippet of the said commands.

enter image description here

Upvotes: 60

Views: 76806

Answers (3)

harsh
harsh

Reputation: 7692

While downloading kibana from x86_64 https://www.elastic.co/downloads/kibana, as of Dec'24, by default it shows aarch64 archival for download.

If aarch64 matches your Mac's architecture, ideally above error "Bad CPU type in executable" should not come. But if it isn't then Mac's architecture mismatch is the primary cause for Bad CPU error.

To check for Mac's architecture type:

Look for the "Chip" or "Processor" line.

  • If it is "Apple M1", "Apple M2" or similar, you have an M1/M2/M3 chip, which is aarch64.
  • If it is "Intel" then you have an Intel chip, which is x86_64.

Upvotes: 0

Shehan Jayalath
Shehan Jayalath

Reputation: 694

I was getting this error when I pushed to a Git repository

chip: Apple M3 Pro

macOS: Sonoma 

version: 14.1

Error:

env: node: Bad CPU type in executable
husky - pre-commit hook exited with code 126 (error)

Solution was:

softwareupdate --install-rosetta

When I ran the above command, I had to agree to the terms by typing 'A'.

I have read and agree to the terms of the software license agreement. A list of Apple SLAs may be found here: https://www.apple.com/legal/sla/
Type A and press return to agree:

Type A and press return to agree: A

Then screen message was:

softwareupdate[276:1180259] Package Authoring Error: 042-41726: Package reference com.apple.pkg.RosettaUpdateAuto is missing installKBytes attribute

Final message was:

Install of Rosetta 2 finished successfully

Upvotes: 1

Mirjalol Bahodirov
Mirjalol Bahodirov

Reputation: 2541

This is CPU related issue. It seems that your MacBook Air's CPU is Apple Silicon (M1).

You need update node version architecture on NVM.

softwareupdate --install-rosetta

Further details can be founded on NVM doc, "Macs with M1 chip" section.

Upvotes: 170

Related Questions