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

Bug: v0.7.0 - Error while requiring module vitest-environment-nuxt/module: Error: Cannot find module 'vitest-environment-nuxt/module' #584

Closed
silverbackdan opened this issue May 16, 2023 · 9 comments

Comments

@silverbackdan
Copy link

silverbackdan commented May 16, 2023

It seems after upgrading to 0.7.0 with vitest 0.31 I receive the error:

Error while requiring module `vitest-environment-nuxt/module`: Error: Cannot find module 'vitest-environment-nuxt/module'

Which looks like it is trying to be installed by the module required for this package.

Strange though as I see vitest-environment-nuxt as a dependency in the package.json

It could be @nuxt/test-utils > vitest conflicting versions. I'll do some digging.

@silverbackdan
Copy link
Author

Perhaps related to the vitest new version and the module package requirements not supporting 0.31

https://github.com/danielroe/nuxt-vitest/blob/main/packages/vitest-environment-nuxt/package.json#L56

@silverbackdan
Copy link
Author

silverbackdan commented May 16, 2023

If using the @nuxt/test-utils package and updating this to the latest version, it requires vitest 0.31 where these packages require up to 0.30. This then seems to cause the error I believe where vitest-environment-nuxt fails to install and causes this error. Otherwise vitest-environment-nuxt seems to install fine in 0.7.0

@silverbackdan
Copy link
Author

Also see another user with this issue in comments of the closed issue here: https://github.com/danielroe/nuxt-vitest/issues/68

@huntz20
Copy link

huntz20 commented May 20, 2023

Same thing happen to me after installing nuxt-vitest

when runing test i getting this error

Error: Failed to load url /packages/nuxt/dist/app/index/entry (resolved id: /packages/nuxt/dist/app/index/entry) in /Users/huntz/WebstormProjects/petal/node_modules/vitest-environment-nuxt/dist/index.mjs. Does the file exist?
    at loadAndTransform (file:///Users/huntz/WebstormProjects/petal/node_modules/vite/dist/node/chunks/dep-4d3eff22.js:53376:21)

@ThomasWT
Copy link

The only way I could make this work was
npm remove vitest @nuxt/test-utils

then installing these 2 with the specific versions.

"nuxt-vitest": "^0.6.8",
"vitest-environment-nuxt": "^0.7.0"

There seems to be a dependency conflict between vitest@0.31.1, @nuxt/test-utils@3.5.0 and nuxt-vitest@0.7.0

@TECH7Fox
Copy link

Also having this issue. Only seems to work with vitest@0.30.1.

@silverbackdan
Copy link
Author

That is because the package.json are currently locked to 0.30.1
https://github.com/danielroe/nuxt-vitest/blob/main/packages/nuxt-vitest/package.json#L46
https://github.com/danielroe/nuxt-vitest/blob/main/packages/vitest-environment-nuxt/package.json#L59
https://github.com/danielroe/nuxt-vitest/blob/main/package.json#L35

A quick PR should resolve these I think, I'll try sort this out.

@silverbackdan
Copy link
Author

silverbackdan commented May 25, 2023

I'm not definite but I'm pretty sure danielroe/nuxt-vitest#185 should resolve this if you wanted to check

My thinking is that although vitest-environment-nuxt is a dependency, the vitest peerDependencies do not match is we use the latest vitest 0.31 but if we switch back to vitest 0.30.1 then it is all resolving - so probably pnpm resolution issue.. not definite but seemed worth a shot.

@danielroe
Copy link
Member

danielroe commented May 30, 2023

This should be resolved in the latest version of Nuxt (v3.5.2) via nuxt/nuxt#21082.

Let me know if not and I'll happily reopen.

@danielroe danielroe transferred this issue from danielroe/nuxt-vitest Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants