Module build results in "error TS2307: Cannot find module or its corresponding type declarations."
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 275
- Forks
- 35
- Avg merge
- 4h 42m
- Merged PRs (30d)
- 6
Description
Environment
- Operating System: Windows_NT
- Node Version: v20.10.0
- Nuxt Version: 3.15.4
- CLI Version: 3.21.1
- Nitro Version: 2.10.4
- Package Manager: npm@10.2.3
- Builder: -
- User Config: -
- Runtime Modules: -
- Build Modules: -
Reproduction
https://github.com/prof-schnitzel/nuxt-ts-bug-module/tree/main
Describe the bug
In my module.ts I have added the line export type * from './runtime/types' so that my nuxt module exports types that can be used in a consumer app. In the types file I only have this line: export * from '../components/MyDiv.vue'. But when running npm run prepack I get the error src/runtime/types/index.ts(1,15): error TS2307: Cannot find module '../components/MyDiv.vue' or its corresponding type declarations. Why? This seems to be a bug to me.
Additional context
No response
Logs
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 linked reproduction and run npm run prepack using the reported environment. Inspect module.ts, src/runtime/types/index.ts, and the referenced runtime/types and components/MyDiv.vue paths to trace why the Vue module cannot be resolved; done means the module builds without TS2307 while exporting the runtime types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100