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

Cannot find module '#imports' or its corresponding type declarations when creating a Nuxt module #22564

Closed
dan-hammond opened this issue Aug 9, 2023 · 2 comments

Comments

@dan-hammond
Copy link

dan-hammond commented Aug 9, 2023

Environment

  • Operating System: Darwin
  • Node Version: v18.16.1
  • Nuxt Version: 3.6.5
  • Nitro Version: 2.5.2
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

See here for a repro: https://github.com/dan-hammond/imports-types-repro

Alternatively, below are the steps to recreate it locally with ease:

npx nuxi init -t module my-module
cd my-module
npm i --legacy-peer-deps
npm run dev:prepare

Create a file like ~/src/runtime/TemplatePage.vue with the following contents:

<template>
  <div>hello {{ world }}</div>
</template>

<script lang="ts" setup>
import {
  computed,
} from "#imports";

const world = computed( () => "world" );
</script>

The error will be immediately apparent.

Describe the bug

When creating a Nuxt module, Vue files in the runtime folder don't seem to pick up the TypeScript aliases generated by Nuxt. It errors with the following:

image

Cannot find module '#imports' or its corresponding type declarations.ts(2307)

For comparison, I cloned nuxt/content and added the same Vue file in that repo's runtime folder, which works as intended. I can't work out what the difference is that causes the issue in a fresh module.

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

This should be resolved by nuxt/starter#392 - would you implement what I've done in that PR and check if it resolves it for you?

@dan-hammond
Copy link
Author

Thanks @danielroe, that works like a charm.

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

2 participants