-
Notifications
You must be signed in to change notification settings - Fork 87
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
Cannot find module 'vitest-environment-nuxt/module' #528
Comments
Would you provide a reproduction? 🙏 My guess is that possibly you haven't set up your vitest config as needed ... |
This is certainly possible, as I'm adding it to an existing project and I am struggling to find documentation to do that (rather than just creating a new app with vite.etc.) |
Unfortunately I cannot seem to get a reproduction working, I can't even get tests to run... not sure what I've missed :/ Have copied my package json, the various config files, and the component I'm wanting to test, but nothing =\
I do however have that installed, needed it locally, and don't see this error. |
You can check out https://github.com/elk-zone/elk/blob/main/vitest.config.mjs to see how one project is configured. |
Ahh, yes, that is a known issue with an open PR to resolve. |
Okay, so no way to show a repro right now? |
Any ideas on the error:
Currently I am unable to write any tests with a nuxt environment requirement. |
Okay so more information, I've realised I'm seeing this with just running the nuxt server, as well. If I remove the vitest plugin, it works as normal. Also, coming back to this error: `ERROR Cannot start nuxt: Cannot find module 'vitest-environment-nuxt/module' 12:01:09 AM
There is no index.js in that folder - is it expecting one? Is that the problem? |
Okay, apologies for the spam - I got passed it. I was actually missing the package for the vitest-evironment-nuxt (this doesn't appear to be mentioned anywhere). installed that, I'm now at the same error as above:
This is now happening locally, so will take a look at the open PR. |
Why not simply creating a new nuxt 3 project on eg. Stackblitz via https://nuxt.new and adding the module and config over there. |
That's exactly what I did, and saw the errors above, which apparently are a known issue and should be resolved shortly - so I can't create a repro to showcase the problem lol |
The latest version of the module includes the fix I mentioned - maybe you can try again now? |
Already tested this morning, definitely fixed. Ty :) |
Just one thing to add, I think the docs/instructions should point to the requirement of the environment package. I had to install it for it to work. |
It seems this issue is back with Vitest version 0.31.0 |
Thanks @kirkbushell , the fix is to install vitest-environment-nuxt npm i -D vitest-environment-nuxt |
This should be resolved in the latest version of Nuxt (v3.5.2) via nuxt/nuxt#21082. |
I've installed nuxt-vitest and seeing this error when trying to run tests, soon as I added the module to the nuxt config.
Unfortunately still new to the JS/TS ecosystem and struggling to debug, here is the full error:
FAIL app/components/registration/EmailForm.vue.spec.ts > Email form
Error: Cannot find module 'vitest-environment-nuxt/module'
Require stack:
❯ Function._resolve [as resolve] node_modules/jiti/dist/jiti.js:1:241025
❯ resolveModule node_modules/@nuxt/kit/dist/index.mjs:260:41
❯ normalizeModule node_modules/@nuxt/kit/dist/index.mjs:469:18
❯ Object.installModule node_modules/@nuxt/kit/dist/index.mjs:451:47
❯ setup node_modules/nuxt-vitest/dist/module.cjs:22:15
❯ normalizedModule node_modules/@nuxt/kit/dist/index.mjs:170:42
❯ installModule node_modules/@nuxt/kit/dist/index.mjs:452:95
❯ initNuxt node_modules/nuxt/dist/index.mjs:2616:7
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: {
"code": "MODULE_NOT_FOUND",
"requireStack": [
"/Users/----/Work/Mine/ho/index.js",
],
}
The text was updated successfully, but these errors were encountered: