#Cannot find module 'astro/config' or its corresponding type declarations.

3 messages · Page 1 of 1 (latest)

kind ridgeBOT
#

Hi @faint halo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Your errors are TypeScript/editor issues, not Astro itself.

From the docs, a fresh Astro project is expected to have:

  • astro.config.mjs importing defineConfig from "astro/config" [Config overview].
  • A tsconfig.json that usually extends one of Astro’s presets like astro/tsconfigs/base, strict, or strictest [TSConfig templates].

Given your messages:

  1. Cannot find module 'astro/config' in astro.config.mjs

    The docs show this as the correct import:

    import { defineConfig } from "astro/config";
    export default defineConfig({});
    

    [Config overview]

    If TypeScript in your editor can’t resolve "astro/config" but astro is in dependencies, 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 that astro.config.mjs is valid and recommended. [astro.config.mjs]

  2. File 'astro/tsconfigs/strict' not found in tsconfig.json

    The 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"]
    }
    

    [TSConfig templates]

#

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/strict specifically not being found,

I can’t give a definitive fix beyond confirming that:

  • Your astro.config.mjs import is in the form the docs expect.
  • Your tsconfig.json should extend one of the documented presets (e.g. astro/tsconfigs/base, strict, or strictest) and that these are expected to exist inside the astro package. [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]

Beyond that, the knowledge sources do not contain enough information to explain or resolve these specific TypeScript resolution errors.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: