-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
getViteConfig() throws an "ERR_MODULE_NOT_FOUND" error #4910
Description
What version of astro are you using?
1.3.1
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
I wanted to use Vitest together with Astro and saw that there is already an example directly within this repository that is based on pull request #4154. So I installed vitest and created a vitest.config.ts that looks like this:
/// <reference types="vitest" />
import { getViteConfig } from 'astro/config';
export default getViteConfig({
test: {},
});But when I try to execute vitest I'm getting the error
$ npx vitest
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/me/project/node_modules/astro/dist/core/config.js' imported from /Users/me/project/node_modules/astro/config.mjsThe issue is that https://github.com/withastro/astro/blob/24bad5a0ad6e3b64d9209aecffd8d0e9181135ad/packages/astro/config.mjs is importing ./dist/core/config.js which does not exist. The correct path would be ./dist/core/config/config.js. I tried to change that locally in my node_modules directory but then I'm getting
TypeError: Cannot read properties of undefined (reading 'config')
at runHookConfigSetup (file:///Users/me/project/node_modules/astro/dist/integrations/index.js:26:37)So the whole settings object here https://github.com/withastro/astro/blob/24bad5a0ad6e3b64d9209aecffd8d0e9181135ad/packages/astro/src/integrations/index.ts is undefined.
Link to Minimal Reproducible Example
https://stackblitz.com/github/withastro/astro/tree/latest/examples/with-vitest
Participation
- I am willing to submit a pull request for this issue.