EAS Build Cache Provider
The `eas-build-cache-provider` package serves as a specialized build cache provider plugin designed for seamless integration with the Expo CLI (specifically EAS Build). Its core functionality is to enable remote caching for build artifacts generated by EAS, which significantly accelerates subsequent build times by reusing cached components. Currently stable around version 18.5.0 (with recent updates up to 18.7.0), this package is typically configured declaratively within an Expo project's `app.json` or `app.config.js` file, making it a configuration-driven tool rather than one that requires direct programmatic imports in application code. The release cadence generally aligns with the broader `eas-cli` ecosystem, providing continuous feature enhancements and bug fixes. It's a critical component for optimizing CI/CD pipelines for Expo applications built with EAS.
Common errors
-
EAS CLI encountered an unexpected error: Missing environment flag for update command.
cause This error occurs when attempting to run `eas update` for an Expo SDK 55+ project without explicitly providing the `--environment` flag.fixModify your `eas update` command to include `--environment <your-environment-name>`. For example: `eas update --branch main --environment production`. -
Error: Cannot find module 'eas-build-cache-provider' from 'your-project-path/node_modules/eas-cli/build/cache/CacheModule.js'
cause The `eas-build-cache-provider` package was not correctly installed as a development dependency or is not accessible within the `node_modules` structure during the EAS build process.fixEnsure you have installed the package correctly by running `npm install --save-dev eas-build-cache-provider` or `yarn add --dev eas-build-cache-provider` in your project's root directory. Verify that `node_modules` is included in your build context. -
Error: EACCES: permission denied, open '/var/folders/.../eas-cli/cache/eas-build-cache.json'
cause The EAS CLI or the build agent lacks the necessary write permissions to its cache directory, often encountered in restricted CI environments or due to incorrect local file permissions.fixAttempt to clear the EAS cache using `eas build:cache --clear`. On local machines, you might also try `rm -rf ~/.eas/` (macOS/Linux). For CI environments, confirm that the build user has appropriate read/write permissions for the `~/.eas/` directory or its equivalent temporary cache locations.
Warnings
- breaking Starting with EAS CLI v18.0.5, the `--environment` flag became a mandatory requirement for `eas update` commands when targeting Expo SDK version 55 or higher. Failing to include this flag will result in an error and prevent updates from being pushed.
- gotcha The `eas-build-cache-provider` is a backend plugin for EAS CLI, primarily configured through `app.json` or `app.config.js`. It is not intended for direct programmatic imports or usage within your application's JavaScript/TypeScript code. Attempting to import and use its symbols directly for application logic is a misapplication and will likely result in unexpected behavior or unnecessary bundle bloat.
- gotcha This package, being part of the `eas-cli` ecosystem, has a minimum Node.js engine requirement of `>=20.0.0`. Using an older Node.js version when running `eas build` or other EAS CLI commands that interact with this plugin may lead to compatibility issues or build failures.
Install
-
npm install eas-build-cache-provider -
yarn add eas-build-cache-provider -
pnpm add eas-build-cache-provider
Imports
- EasBuildCacheProvider
const EasBuildCacheProvider = require('eas-build-cache-provider');import EasBuildCacheProvider from 'eas-build-cache-provider';
- BuildCacheProviderPlugin
import type { BuildCacheProviderPlugin } from 'eas-build-cache-provider'; - EasBuildCacheProviderConfig
import type { EasBuildCacheProviderConfig } from 'eas-build-cache-provider';
Quickstart
{
"expo": {
"name": "MyExpoApp",
"slug": "my-expo-app",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"favicon": "./assets/favicon.png"
},
"experiments": {
"buildCacheProvider": "eas" // Enable the EAS remote build cache
}
}
}
// To use this configuration:
// 1. Install the package as a development dependency:
// npm install --save-dev eas-build-cache-provider
// 2. Run an EAS build from your project directory:
// eas build --platform android --profile development