【问题标题】:Gulp not working on M1 MacBook Pro with OS MontereyGulp 无法在带有 OS Monterey 的 M1 MacBook Pro 上工作
【发布时间】:2021-12-27 09:04:54
【问题描述】:

所以我试图让 gulp 在我的 M1 MacBook Pro 上运行,但到目前为止收效甚微。

我尝试了很多方法,从删除 package.json 到尝试使用 sudo 安装,但一切都给了我这个错误。

gulp 错误信息:

【问题讨论】:

  • 这能回答你的问题吗? Node Sass with apple m1, Big Sur and arm64
  • @connexo 我已经尝试了该帖子中的所有内容,但没有任何效果:(
  • 如果你从 gulp 方程中根除 sass,gulp 还是不行吗?
  • @connexo 我为什么要这样做?
  • 因为我认为 gulp 在 M1 上没有任何问题,这就是您的问题所声称的。缩小问题范围,提出更准确的问题。

标签: macos npm gulp 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)

*来源:Failed to "nvm install 8.0.0" 来源:https://github.com/nvm-sh/nvm

【讨论】:

    猜你喜欢
    • 2022-09-29
    • 2021-12-26
    • 2022-07-27
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    • 2021-05-08
    • 2023-02-17
    相关资源
    最近更新 更多