heroku login error : line 45, Bad CPU type in executable

% brew tap heroku/brew && brew install heroku
zsh: command not found: brew
% brew -v
zsh: command not found: brew

# Homebrew install (このコマンドは、不要かも)
% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# PATH を通す
% echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/"XXXX"/.zprofile
zsh: parse error near `)'
 % eval "$(/opt/homebrew/bin/brew shellenv)"
 % brew -v
Homebrew 4.0.15
# Heroku install
% brew tap heroku/brew && brew install heroku

% heroku login
/opt/homebrew/bin/heroku: line 45: /opt/homebrew/opt/heroku-node/bin/node: Bad CPU type in executable

# 一旦、heroku を削除
 % brew uninstall heroku
Uninstalling /opt/homebrew/Cellar/heroku/7.68.2... (22,642 files, 66.5MB)
 % rm -rf ~/.local/share/heroku ~/Library/Caches/heroku

# M1 or M2 チップの人は、以下のコマンドで、Rosetta をインストールする
 % softwareupdate --install-rosetta
I have read and agree to the terms of the software license agreement. A list of Apple SLAs may be found here: http://www.apple.com/legal/sla/
Type A and press return to agree: a
 softwareupdate[XXXX:XXXX] Package Authoring Error: 032-66590: Package reference com.apple.pkg.RosettaUpdateAuto is missing installKBytes attribute
Install of Rosetta 2 finished successfully

# 再度 Heroku install
% brew tap heroku/brew && brew install heroku

/opt/homebrew/bin/heroku: line 45: /opt/homebrew/opt/heroku-node/bin/node: Bad CPU type in executable
上記のエラーをググれば、「Rosetta をインストールする必要がある」とわかります。

Rosetta とは、Intel チップではない、つまり、M1, M2チップの Mac PC向けに、Intel チップでしか動作しない App を動かすためのもの。

###############

参考サイト:

how to install rosetta 2 とググると出てきた。