Mac m1芯片使用Nvm包管理安装Node失败
YGHub·2024-11-07·2·字数:267 字·阅读时间:1 分钟
bash
In file included from ../deps/v8/src/compiler/backend/gap-resolver.cc:5:In file included from ../deps/v8/src/compiler/backend/gap-resolver.h:8:In file included from ../deps/v8/src/compiler/backend/instruction.h:14:In file included from ../deps/v8/src/codegen/external-reference.h:9:In file included from ../deps/v8/src/runtime/runtime.h:11:../deps/v8/src/base/bit-field.h:43:29: error: integer value 31 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion] static constexpr T kMax = static_cast<T>(kNumValues - 1); ^../deps/v8/src/base/bit-field.h:43:29: error: integer value 3 is outside the valid range of values [0, 1] for this enumeration type [-Wenum-constexpr-conversion]../deps/v8/src/base/bit-field.h:43:29: error: integer value 31 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]1 error generated.make[1]: *** [/Users/sz/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj.target/v8_compiler/deps/v8/src/compiler/all-nodes.o] Error 1make[1]: *** Waiting for unfinished jobs....../deps/v8/src/base/bit-field.h:43:29: error: integer value 3 is outside the valid range of values [0, 1] for this enumeration type [-Wenum-constexpr-conversion]../deps/v8/src/base/bit-field.h:43:29: error: integer value 3 is outside the valid range of values [0, 1] for this enumeration type [-Wenum-constexpr-conversion]../deps/v8/src/base/bit-field.h:43:29: error: integer value 31 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]../deps/v8/src/base/bit-field.h:43:29: error: integer value 31 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]3 errors generated.make[1]: *** [/Users/sz/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj.target/v8_compiler/deps/v8/src/compiler/backend/frame-elider.o] Error 11 error generated.make[1]: *** [/Users/sz/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj.target/v8_compiler/deps/v8/src/compiler/add-type-assertions-reducer.o] Error 13 errors generated.make[1]: *** [/Users/sz/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj.target/v8_compiler/deps/v8/src/compiler/backend/gap-resolver.o] Error 1../deps/v8/src/base/bit-field.h:43:29: error: integer value 7 is outside the valid range of values [0, 3] for this enumeration type [-Wenum-constexpr-conversion]../deps/v8/src/base/bit-field.h:43:29: error: integer value 7 is outside the valid range of values [0, 3] for this enumeration type [-Wenum-constexpr-conversion]../deps/v8/src/base/bit-field.h:43:29: error: integer value 7 is outside the valid range of values [0, 3] for this enumeration type [-Wenum-constexpr-conversion]2 errors generated.make[1]: *** [/Users/sz/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj.target/v8_compiler/deps/v8/src/compiler/access-builder.o] Error 12 errors generated.make[1]: *** [/Users/sz/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj.target/v8_compiler/deps/v8/src/compiler/access-info.o] Error 14 errors generated.make[1]: *** [/Users/sz/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj.target/v8_compiler/deps/v8/src/compiler/backend/code-generator.o] Error 1rm 408972061c1664f35c2c74803977a61cc7386e59.intermediate a54aefff34cb8bf0a5a4e4a745072a7862d83a31.intermediate 8b44876edf628e34913eba24c0f7ed712d298aae.intermediatemake: *** [node] Error 2nvm: install v14.21.3 failed!
错误原因
某些特定版本的 Node.js 可能对 M1 芯片有兼容性问题。如果你使用的 Node.js 版本与 M1 芯片不完全兼容,尝试安装 node 的最新 LTS 版本:
bash
nvm install --lts
解决方案
1. 安装 Rosetta 2
由于某些 Node.js 版本可能未完全支持 ARM 架构,使用 Rosetta 2 可以帮助在 M1 芯片上运行基于 x86 架构的程序。
bash
sudo softwareupdate --install-rosetta
2. 使用 Rosetta 运行终端
你可以通过 Rosetta 运行终端,然后再使用 nvm 安装 Node.js:
• 找到 Terminal 应用程序。
• 右键点击 Terminal,选择 显示详情。
• 勾选 Open using Rosetta。
3. 安装和配置 nvm
确保你已经正确安装并配置了 nvm。可以使用以下命令:
bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
安装完成后,重新加载 shell 配置文件,或手动运行以下命令:
bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
4. 安装特定的 Node.js 版本
通过 nvm 安装指定的 Node.js 版本:
bash
nvm install 14 # 或者你需要的其他版本
Preview
2
点个赞 ~
版权申明: © 本文著作权归YGHub所有,未经YGHub网授权许可,禁止第三方以任何形式转载和使用本文内容。
Related article
基于微信小程序实现图片压缩、裁剪、尺寸调整的实践总结
YGHub
2025-01-02
4
Vue3 作用域插槽,提升组件复用性的利器
YGHub
2024-12-03
1
Nuxt3 中使用 localStorage 的正确姿势
YGHub
2024-12-01
3
Vue3 子组件 defineExpose 暴露方法无效的三种常见场景及解决方案
YGHub
2024-11-24
7
Vue3 组件通信实战,实现跨组件数据更新
YGHub
2024-11-21
8