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

迁移至Eas Build时遇jsonfile/utils模块缺失错误,如何解决?

问题描述

我正从expo build迁移至eas-build,已创建简易的eas.json文件,但卡在了这个(希望是最后一个)错误上。此前未使用.env文件,因此确定这不是问题所在。

package.json片段

"expo": "^41.0.0",
"react": "17.0.2",
"react-native": "0.63.4",

eas.json内容

{
  "cli": {
    "version": ">= 2.1.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    },
    "production": {}
  },
  "submit": {
    "production": {}
  }
}

错误日志

在Expo的"run gradlew"步骤中出现如下错误:

> Task :app:createReleaseExpoConfig FAILED
[stderr] node:internal/modules/cjs/loader:936
[stderr]   throw err;
[stderr]   ^
[stderr] Error: Cannot find module 'jsonfile/utils'
[stderr] Require stack:
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/node_modules/fs-extra/lib/json/output-json.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/node_modules/fs-extra/lib/json/index.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/node_modules/fs-extra/lib/index.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/build/ios/index.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/build/index.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config-plugins/build/android/SplashScreen.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config-plugins/build/android/index.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config-plugins/build/index.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config/build/plugins/withConfigPlugins.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config/build/Config.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config/build/index.js
[stderr] - /home/expo/workingdir/build/node_modules/expo-constants/scripts/getAppConfig.js
[stderr]     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
[stderr]     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
[stderr]     at Module.require (node:internal/modules/cjs/loader:1005:19)
[stderr]     at require (node:internal/modules/cjs/helpers:102:18)
[stderr]     at Object.<anonymous> (/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/node_modules/fs-extra/lib/json/output-json.js:3:23)
[stderr]     at Module._compile (node:internal/modules/cjs/loader:1101:14)
[stderr]     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
[stderr]     at Module.load (node:internal/modules/cjs/loader:981:32)
[stderr]     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
[stderr]     at Module.require (node:internal/modules/cjs/loader:1005:19) {
[stderr]   code: 'MODULE_NOT_FOUND',
[stderr]   requireStack: [
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/node_modules/fs-extra/lib/json/output-json.js',
[stderr] '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/node_modules/fs-extra/lib/json/index.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/node_modules/fs-extra/lib/index.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/build/ios/index.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/configure-splash-screen/build/index.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config-plugins/build/android/SplashScreen.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config-plugins/build/android/index.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config-plugins/build/index.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config/build/plugins/withConfigPlugins.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config/build/Config.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/node_modules/@expo/config/build/index.js',
[stderr]     '/home/expo/workingdir/build/node_modules/expo-constants/scripts/getAppConfig.js'
[stderr]   ]
[stderr] }
> Task :unimodules-permissions-interface:packageReleaseResources
> Task :unimodules-image-loader-interface:packageReleaseResources
> Task :unimodules-react-native-adapter:packageReleaseResources
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:createReleaseExpoConfig'.
[stderr] > Process 'command 'node'' finished with non-zero exit value 1
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 2m 16s
解决方案

这个错误源于fs-extra依赖的jsonfile包版本不兼容或依赖未正确安装,可按以下步骤解决:

  • 清理并重装依赖
    删除本地node_modules文件夹、package-lock.json/yarn.lock文件,再执行npm install或yarn install重新安装依赖。

  • 锁定jsonfile版本
    在package.json中添加resolutions字段强制指定兼容版本:

    "resolutions": {
      "jsonfile": "^6.1.0"
    }
    

    npm用户需先执行npx npm-force-resolutions再重装依赖,yarn用户直接执行yarn install即可。

  • 升级Expo相关包
    当前使用的Expo 41.0.0版本较旧,存在依赖兼容风险。可执行expo upgrade 41升级到该版本的最新补丁,或按官方指引升级到更高稳定版本(注意匹配React Native版本)。

  • 禁用EAS构建缓存
    若本地构建正常但远程EAS构建仍出错,可在eas.json中为对应构建环境添加缓存禁用配置:

    "build": {
      "preview": {
        "distribution": "internal",
        "android": {
          "buildType": "apk"
        },
        "cache": {
          "disabled": true
        }
      }
    }
    

内容的提问来源于stack exchange,提问作者Khaleel

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 10:10:30