“nvm install 8.0.0”失败

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

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

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

但是每当我尝试运行

nvm install 8
我都会收到错误
error: "unsupported ARM architecture"

我的系统是 MacOS Big Sur M1 芯片

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

node.js gulp macos-big-sur nvm
2个回答
10
投票

解决方案

解决方案是将我的 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(当您第一次打开仅限 Intel 的非命令行应用程序时,macOS 会提示您安装 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


3
投票

以下步骤将允许您安装节点 8。

  • 在Finder中找到iTerm(或其他终端)应用程序

  • 按住 Control 键并单击图标,选择“获取信息”

  • 综合面板:
    ✅ 使用Rosetta打开(选择此项)

  • 关闭并重新打开终端

  • 您现在可以使用

    nvm install 8

© www.soinside.com 2019 - 2024. All rights reserved.