#Cannot find module 'astro/config' or its corresponding type declarations.
3 messages · Page 1 of 1 (latest)
Your errors are TypeScript/editor issues, not Astro itself.
From the docs, a fresh Astro project is expected to have:
astro.config.mjsimportingdefineConfigfrom"astro/config"[Config overview].- A
tsconfig.jsonthat usuallyextendsone of Astro’s presets likeastro/tsconfigs/base,strict, orstrictest[TSConfig templates].
Given your messages:
-
Cannot find module 'astro/config'inastro.config.mjsThe docs show this as the correct import:
import { defineConfig } from "astro/config"; export default defineConfig({});If TypeScript in your editor can’t resolve
"astro/config"butastrois independencies, this is usually a TS configuration / tooling problem, not an Astro config problem. The docs don’t provide specific troubleshooting steps for this case, only thatastro.config.mjsis valid and recommended. [astro.config.mjs] -
File 'astro/tsconfigs/strict' not foundintsconfig.jsonThe docs state that you can extend Astro’s presets like this:
{ "extends": "astro/tsconfigs/base" }or with includes/excludes:
{ "extends": "astro/tsconfigs/base", "include": [".astro/types.d.ts", "**/*"], "exclude": ["dist"] }
They also mention three templates: base, strict, and strictest, and that you can view them in astro/tsconfigs/ [Manual setup – Add TypeScript support; TSConfig templates]. However, the knowledge sources do not explain why astro/tsconfigs/strict would be missing in your installation or how to fix that specific error.
Because the provided docs don’t include troubleshooting for:
- TypeScript not resolving
"astro/config"in a fresh install, or astro/tsconfigs/strictspecifically not being found,
I can’t give a definitive fix beyond confirming that:
- Your
astro.config.mjsimport is in the form the docs expect. - Your
tsconfig.jsonshould extend one of the documented presets (e.g.astro/tsconfigs/base,strict, orstrictest) and that these are expected to exist inside theastropackage. [TSConfig templates]
If you want to align strictly with the docs, you could temporarily change your tsconfig.json to:
{
"extends": "astro/tsconfigs/base",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"]
}
as shown in the TypeScript guide, and see whether that changes the behavior in your editor. [TSConfig templates]