执行gatsby develop报错:未找到对应平台的原生构建文件
解决Gatsby develop时@parcel/watcher的native build缺失错误
问题描述
更新所有依赖包和Node版本后,运行gatsby develop出现以下编译错误:
verbose set gatsby_log_level: "verbose" verbose set gatsby_executing_command: "develop" verbose loading local command from: /Users/XXXXX/Code/site/website/node_modules/gatsby/dist/commands/develop.js verbose running command: develop verbose Transition to "initializing" ERROR #11903 API.TYPESCRIPT.COMPILATION There was an unhandled error during compilation for /Users/XXXXX/Code/site/website. Please run the command with the --verbose flag again. No native build was found for platform=darwin arch=x64 runtime=node abi=111 uv=1 libc=glibc node=19.7.0 loaded from: /Users/XXXXX/Code/site/website/node_modules/@parcel/watcher Error: No native build was found for platform=darwin arch=x64 runtime=node abi=111 uv=1 libc=glibc node=19.7.0 loaded from: /Users/XXXXX/Code/site/website/node_modules/@parcel/watcher - node-gyp-build.js:60 Function.load.resolve.load.path [el-party-info]/[node-gyp-build]/node-gyp-build.js:60:9 - node-gyp-build.js:22 load [el-party-info]/[node-gyp-build]/node-gyp-build.js:22:30 - index.js:1 Object.<anonymous> [el-party-info]/[@parcel]/watcher/index.js:1:42 - loader:1275 Module._compile node:internal/modules/cjs/loader:1275:14 - loader:1329 Object.Module._extensions..js node:internal/modules/cjs/loader:1329:10 - loader:1133 Module.load node:internal/modules/cjs/loader:1133:32 - loader:972 Function.Module._load node:internal/modules/cjs/loader:972:12 - loader:1157 Module.require node:internal/modules/cjs/loader:1157:19 - helpers:119 require node:internal/modules/helpers:119:18 - index.js:7 Object.<anonymous> [el-party-info]/[@parcel]/fs/lib/index.js:7:28 - loader:1275 Module._compile node:internal/modules/cjs/loader:1275:14 - loader:1329 Object.Module._extensions..js node:internal/modules/cjs/loader:1329:10 - loader:1133 Module.load node:internal/modules/cjs/loader:1133:32 - loader:972 Function.Module._load node:internal/modules/cjs/loader:972:12 - loader:1157 Module.require node:internal/modules/cjs/loader:1157:19 - helpers:119 require node:internal/modules/helpers:119:18 not finished compile gatsby files - 0.085s
环境:MacOS 13.0,nvm管理Node版本,Node 18/19均出现此问题。
解决方案
1. 彻底清理依赖并重装
- 删除本地依赖文件和锁文件:
rm -rf node_modules package-lock.json yarn.lock - 清空npm缓存:
npm cache clean --force - 重新安装依赖:
npm install
2. 强制重新构建@parcel/watcher的原生模块
如果重装后问题依旧,直接针对该包从源码构建:
npm install @parcel/watcher --build-from-source # 或者用rebuild命令 npm rebuild @parcel/watcher
3. 切换到兼容的Node LTS版本
部分旧版@parcel/watcher对Node 19的支持不完善,建议切换到Node 18的稳定LTS版本(如18.17.0):
nvm install 18.17.0 nvm use 18.17.0
切换后重复步骤1的清理和重装操作。
4. 确保系统构建工具完整
MacOS下需要Xcode命令行工具来编译原生模块,检查并安装:
xcode-select --install
安装完成后再重新执行依赖安装或构建命令。
内容的提问来源于stack exchange,提问作者Kyle Calica-St
相关产品推荐
相关产品推荐

