#Cannot build in Starlight

3 messages · Page 1 of 1 (latest)

violet ferry
#

This is a Starlight project. When I use npm run dev it works normally in the browser. But when I try to deploy it or use npm run build it occurs as below:

src/pages/zh-cn/index.astro:4:27 - error ts(2307): Cannot find module '@a
strojs/starlight/components/StarlightPage.astro' or its corresponding type declarations.

4 import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
zinc oasisBOT
#

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

#

The error message indicates that the module '@astrojs/starlight/components/StarlightPage.astro' cannot be found. This could be due to a few reasons:

  1. The Starlight package might not be installed correctly. You can add it to your site by running the astro add command in your project’s root directory:
npx astro add starlight

or

pnpm astro add starlight

or

yarn astro add starlight

This will install the required dependencies and add Starlight to the integrations array in your Astro config file. source (https://starlight.astro.build/manual-setup/#set-up-starlight)

  1. There might be a typo in the import statement. Make sure the path to the module is correct.

  2. If you're using TypeScript, you might need to run a type check. You can do this by changing your “build” script in package.json to the following:

"scripts": {
  "build": "astro check && astro build",
}

This will prevent your code from building if it contains TypeScript errors. source (https://docs.astro.build/en/guides/typescript/#type-checking)

If none of these solutions work, you might want to check the official Astro and Starlight documentation or their respective GitHub repositories for more information.

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