【问题标题】:Failed to "nvm install 8.0.0"无法“nvm install 8.0.0”
【发布时间】:2021-06-23 17:09:19
【问题描述】:

我的目标是安装节点版本 8,以便我可以在项目上运行 Gulp

我正在处理一个旧项目,该项目已被另一位开发人员忽略并传给了我。有人告诉我,我可以通过安装 Node 版本 8 并在我的 package.json 文件中声明节点版本来使用 Gulp。

但每当我尝试运行nvm install 8时,我都会收到错误error: "unsupported ARM architecture"

我的系统是 MacOS Big Sur M1 芯片

我不太确定我应该在这里做什么。请帮忙!

【问题讨论】:

  • 这是带有 M1 芯片组的 Mac 吗?
  • @madflow 是的,它是带有 M1 芯片组的 Mac。我已更新问题以展示 M1 芯片组

标签: node.js gulp macos-big-sur nvm


【解决方案1】:

解决方案

解决方案是将我的 shell 架构从 arm64 更改为 x86。

配备 M1 芯片的 Mac

2021 年 1 月:对于 Apple 的新 M1 芯片(arm64 架构),15.x 之前的版本没有预编译的 NodeJS 二进制文件。

您可能会遇到的一些问题:

  1. 使用 nvm 安装,例如 v14.15.4:
  • C 代码编译成功
  • 但在使用时会因内存不足错误而崩溃
  • 增加节点可用的内存仍然会产生内存不足错误:$ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/your_node_package
  1. 使用nvm安装部分版本时,编译失败

解决此问题的一个方法是将您的 shell 架构从 arm64 更改为 x86。

假设:

  • 您已经使用 nvm 安装了 12.20.1 和 14.15.4 版本
  • 当前使用的版本是 14.15.4
  • 你正在使用 zsh shell
  • 您已安装 Rosetta 2(macOS 会在您第一次打开仅限 Intel 的非命令行应用程序时提示您安装 Rosetta 2,或者您可以使用 softwareupdate --install-rosetta 从命令行安装 Rosetta 2)
//# 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)

来源:https://github.com/nvm-sh/nvm

【讨论】:

    【解决方案2】:
    • 查找 UR iTerm(或您使用的任何其他术语)

    • 双击=>【获取信息】

    • 一般面板:
      ✅ 使用 Rosetta 打开(已选择此项)

    • 返回终端并继续使用nvm install 8

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    • 2020-10-22
    • 2022-06-14
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    相关资源
    最近更新 更多