{"record":{"id":"522a3d35a478223a","repo":"withastro/astro","slug":"cacheprovidernotfound","errorCode":"CacheProviderNotFound","errorMessage":"Could not resolve the cache provider `${provider}`. Make sure the package is installed.","messagePattern":"Could not resolve the cache provider `(.+?)`\\. Make sure the package is installed\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/cache/vite-plugin.ts","lineNumber":52,"sourceCode":"\t\tload: {\n\t\t\tfilter: {\n\t\t\t\tid: new RegExp(`^${RESOLVED_VIRTUAL_CACHE_PROVIDER_ID}$`),\n\t\t\t},\n\t\t\tasync handler() {\n\t\t\t\tconst provider = normalizeCacheProviderConfig(providerConfig);\n\t\t\t\t// Use the project root as the importer so that adapter-provided\n\t\t\t\t// providers (e.g. astro/cache/memory) resolve from the project's\n\t\t\t\t// node_modules, not from astro core's location.\n\t\t\t\tconst importerPath = fileURLToPath(new URL('package.json', settings.config.root));\n\t\t\t\tlet resolved;\n\t\t\t\ttry {\n\t\t\t\t\tresolved = await this.resolve(provider.entrypoint, importerPath);\n\t\t\t\t} catch {\n\t\t\t\t\t// Resolution can throw for invalid package specifiers\n\t\t\t\t}\n\t\t\t\tif (!resolved) {\n\t\t\t\t\tconst displayName = provider.name ?? provider.entrypoint;\n\t\t\t\t\tthrow new AstroError({\n\t\t\t\t\t\t...CacheProviderNotFound,\n\t\t\t\t\t\tmessage: CacheProviderNotFound.message(displayName),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcode: `import { default as _default } from '${resolved.id}';\\nexport * from '${resolved.id}';\\nexport default _default;`,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t};\n}\n","sourceCodeStart":34,"sourceCodeEnd":65,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/cache/vite-plugin.ts#L34-L65","documentation":"During Vite's dev-server module resolution, the cache plugin tries to resolve the provider's `entrypoint` specifier from the project's `node_modules` (using `package.json` at the project root as importer). If `this.resolve(...)` returns nothing or throws, the provider package is considered missing and Astro throws `CacheProviderNotFound`. This catches typo'd package names and uninstalled adapter-provided providers at startup.","triggerScenarios":"Configuring `cache: { provider: { name: 'redis', entrypoint: 'astro-cache-redis' } }` when `astro-cache-redis` is not installed; referencing a provider exported by an adapter that hasn't been added; a monorepo where the provider lives in a workspace package not hoisted to the project root's `node_modules`.","commonSituations":"Forgetting to `npm install` the provider package; using a private/scoped provider that isn't published; pnpm strict-node-modules layout preventing resolution from the project root; typo in the entrypoint string.","solutions":["Install the missing provider package: `npm install <provider-entrypoint>`.","Confirm the `entrypoint` string matches the published package name exactly (check the provider's README).","For monorepos/pnpm, ensure the provider is a direct dependency of the project root, not only of a workspace package.","If the provider ships via an adapter, make sure the adapter is registered in `integrations` before referencing its provider."],"exampleFix":"// before — astro.config.mjs\nimport { defineConfig } from 'astro/config';\nexport default defineConfig({\n  cache: { provider: { name: 'redis', entrypoint: 'astro-cache-redis' } },\n});\n\n// after\nnpm install astro-cache-redis","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst { createRequire } = require('module');\nconst req = createRequire(projectRoot + '/');\ntry { req.resolve(providerEntrypoint); } catch { throw new Error('Install provider: ' + providerEntrypoint); }","typeGuard":"function providerResolvable(entrypoint, root) {\n  const req = createRequire(root + '/package.json');\n  try { req.resolve(entrypoint); return true; } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Install provider packages as direct dependencies of the project root.","Add a CI step that verifies cache providers resolve before build.","Pin provider versions to avoid silent breakage on registry changes."],"tags":["cache","configuration","dependency-resolution","vite"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}