📄 expo/build-reference/npm-cache-with-yarn

File: npm-cache-with-yarn.md | Updated: 11/15/2025

Source: https://docs.expo.dev/build-reference/npm-cache-with-yarn

Hide navigation

Search

Ctrl K

Home Guides EAS Reference Learn

Archive Expo Snack Discord and Forums Newsletter

Using npm cache with Yarn 1 (Classic)

Edit page

Copy page

Learn how to use npm cache by overriding the registry in Yarn 1 (Classic).

Edit page

Copy page


By default, the EAS npm cache won't work with Yarn 1 (Classic) because yarn.lock files contain URLs to registries for every library. Yarn 1 does not provide any way to override it and Yarn team does not plan to support it in Yarn 1. However, this issue is fixed in Yarn 2+.

If you want to take advantage of the npm cache with Yarn 1, add the eas-build-pre-install npm hook in package.json to override the registry in the yarn.lock:

package.json

Copy

{ "scripts": { "eas-build-pre-install": "bash -c \"[ ! -z \\\"$EAS_BUILD_NPM_CACHE_URL\\\" ] && sed -i -e \\\"s#https://registry.yarnpkg.com#$EAS_BUILD_NPM_CACHE_URL#g\\\" yarn.lock\" || true" } }