You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac M2 Sonoma 14.4.1环境下安装NativeScript失败求助

解决Mac(arm64)安装NativeScript时fsevents编译报错问题

问题核心

报错根源是fsevents依赖编译失败,具体表现为找不到binding.gyp文件,主要由以下因素导致:

  • Node.js 21.x为开发版(奇数版本),与nativescript/node-gyp兼容性不足
  • Python 3.12对node-gyp的支持不完善
  • 安装过程中缓存或依赖包损坏

解决方案

1. 切换到Node.js LTS版本

NativeScript官方推荐使用LTS版本(如20.x),避免开发版的兼容性问题:

  • 用nvm管理版本(推荐):
    # 安装nvm(未安装时执行)
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    # 安装Node.js 20.x LTS
    nvm install 20
    # 设置为默认版本
    nvm alias default 20
    
  • 用Homebrew安装:
    brew uninstall node
    brew install node@20
    brew link node@20 --force --overwrite
    

2. 指定兼容的Python版本

Python 3.12与node-gyp存在兼容性问题,降级到3.11并配置给npm:

brew install python@3.11
# 配置npm使用指定Python版本
npm config set python /opt/homebrew/opt/python@3.11/bin/python3.11

3. 清理缓存并重新安装

# 清理npm缓存
npm cache clean --force
# 卸载不完整的全局nativescript
npm uninstall -g nativescript
# 重新安装
npm install -g nativescript

备选方案(临时跳过编译,不推荐)

如果上述步骤仍报错,可临时跳过脚本编译(可能影响部分功能):

npm install -g nativescript --ignore-scripts

额外检查

确保已安装Xcode命令行工具:

xcode-select --install

内容的提问来源于stack exchange,提问作者David Durà

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 16:33:18