From a13c29affd955adb298ea83d53652918e3ece2d5 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Tue, 10 Mar 2026 22:00:20 -0700 Subject: [PATCH] build: isolate yarn cache when running verdaccio --- tools/verdaccio/spawn-verdaccio.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/verdaccio/spawn-verdaccio.ts b/tools/verdaccio/spawn-verdaccio.ts index 50b15842d1..fedeff7818 100644 --- a/tools/verdaccio/spawn-verdaccio.ts +++ b/tools/verdaccio/spawn-verdaccio.ts @@ -137,6 +137,12 @@ async function runCommand(args: string[]) { console.log('🗑️ Pruning pnpm store before running command'); await spawnPromise('pnpm', ['store', 'prune']); + /** + * Avoid polluting the global yarn cache. + */ + const tempYarnGlobal = path.join(STORAGE_PATH, '.yarn-global'); + fs.promises.mkdir(tempYarnGlobal, { recursive: true }); + console.log(`🏃 Running: ${args.join(' ')}`); console.log(` Using registry: ${VERDACCIO_URL}`); @@ -152,6 +158,13 @@ async function runCommand(args: string[]) { YARN_NPM_REGISTRY_SERVER: VERDACCIO_URL, // https://yarnpkg.com/configuration/yarnrc#unsafeHttpWhitelist YARN_UNSAFE_HTTP_WHITELIST: LOCALHOST, + // Isolate package manager caches so Verdaccio packages + // don't corrupt the global caches. These directories live + // under STORAGE_PATH and get cleaned up on next run. + // https://yarnpkg.com/configuration/yarnrc#globalFolder + YARN_GLOBAL_FOLDER: tempYarnGlobal, + // https://yarnpkg.com/configuration/yarnrc#enableGlobalCache + YARN_ENABLE_GLOBAL_CACHE: 'false', }, }); }