Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getViteConfig() throws an "ERR_MODULE_NOT_FOUND" error #4910

Closed
1 task done
screendriver opened this issue Sep 28, 2022 · 3 comments · Fixed by #5013
Closed
1 task done

getViteConfig() throws an "ERR_MODULE_NOT_FOUND" error #4910

screendriver opened this issue Sep 28, 2022 · 3 comments · Fixed by #5013
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)

Comments

@screendriver
Copy link

screendriver commented Sep 28, 2022

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.mjs

The 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.
@rishi-raj-jain
Copy link
Contributor

@screendriver is the current example not working or you tried that approach in a new project and that didn't work?

@screendriver
Copy link
Author

Both.

@rishi-raj-jain
Copy link
Contributor

Aight, me is diving into this!

@matthewp matthewp added the - P3: minor bug An edge case that only affects very specific usage (priority) label Sep 29, 2022
@matthewp matthewp added - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) and removed - P3: minor bug An edge case that only affects very specific usage (priority) labels Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants