zsh:可执行文件中的 CPU 类型错误:node

问题描述 投票:0回答:2

我已经使用brew安装了nvm。之后,我通过nvm安装了16版本的node,并使用node -v检查当前版本,看看node是否正常工作。但是,当我安装版本 14 或任何其他以前的版本并运行 node -v 时,它会给出“zsh:可执行文件中的 CPU 类型错误:节点”消息,但我不知道该怎么做,安装 Node v17 和运行 node -v 按预期工作。以下是上述命令的片段。

node.js zsh nvm
2个回答
150
投票

这是与 CPU 相关的问题。看来您的 MacBook Air 的 CPU 是 Apple Silicon (M1)。

您需要更新 NVM 上的节点版本架构。

softwareupdate --install-rosetta

更多详细信息可参见 NVM 文档,“配备 M1 芯片的 Mac”部分。


0
投票

当我推送到 Git 存储库时遇到此错误

错误:

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

解决方案是:

softwareupdate --install-rosetta

当我运行上述命令时,我必须输入“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

然后屏幕消息是:

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

最终消息是:

Install of Rosetta 2 finished successfully
© www.soinside.com 2019 - 2024. All rights reserved.