Error: This module cannot be imported in the Vue part of your app
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 437
- Forks
- 120
- Avg merge
- 22h 52m
- Merged PRs (30d)
- 23
Description
Environment
- Operating System: Linux
- Node Version: v18.18.0
- Nuxt Version: 3.9.3
- CLI Version: 3.10.0
- Nitro Version: 2.8.1
- Package Manager: npm@10.2.3
- Builder: -
- User Config: devtools, modules
- Runtime Modules: @nuxt/test-utils/module@3.11.0
- Build Modules: -
Reproduction
https://stackblitz.com/edit/github-3etpwp?file=package.json
Describe the bug
If you have test files in your pages folder importing @nuxt/test-utils/runtime, the following error pops up when starting the project
ERROR This module cannot be imported in the Vue part of your app. [importing @nuxt/test-utils/runtime from pages/<testname>.ts]
The error does not seem to have effect on the app startup itself (it's probably more a warning).
The error goes away when moving the test out of the pages folder.
Additional context
No response
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the StackBlitz reproduction and package.json, then inspect how @nuxt/test-utils/runtime is imported from pages/.ts. Confirm the startup error with a test file under pages and compare it after moving the file; done should define whether the warning is removed or otherwise handled without affecting app startup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- frontend, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100