nuxt-open-fetch icon indicating copy to clipboard operation
nuxt-open-fetch copied to clipboard

Cannot find module '#open-fetch-schemas/..."

Open schillerenrico opened this issue 1 year ago • 8 comments

Environment

Nuxt 4

Reproduction

Start a project with nuxt-open-fetch 0.9.1 and start it with npm run dev npm update to get to version 0.9.2 and start again

Describe the bug

inside .nuxt\open-fetch.ts the import type { paths as ... throws the following error inside the IDE Cannot find module '#open-fetch-schemas/***' or its corresponding type declarations.

but it works in 0.9.1 not in 0.9.2

Additional context

you need to run "npm run dev" after changing from 0.9.1 to 0.9.2 to see the error inside .nuxt\open-fetch.ts

Logs

No response

schillerenrico avatar Sep 17 '24 16:09 schillerenrico

For now I am using

"devDependencies": { "nuxt-open-fetch": "0.9.1",...

not 0.9.2 to have a working project in my IDE. Cause otherwise all the endpoints have an any type

schillerenrico avatar Sep 17 '24 16:09 schillerenrico

@schillerenrico are you still able to reproduce it?

Norbiros avatar Jul 19 '25 16:07 Norbiros

I run into this issue as well. It's odd, since the generated ./nuxt/tsconfig.json does seem to have the right entries:

      "#open-fetch": [
        "./open-fetch"
      ],
      "#open-fetch-schemas/*": [
        "./types/open-fetch/schemas/*"
      ],

The IDE (Cursor) picks it up fine, but a nuxt typecheck fails on it 🤔

TheDutchCoder avatar Jul 22 '25 22:07 TheDutchCoder

On which version? 0.13 or something below?

Norbiros avatar Jul 23 '25 13:07 Norbiros

On which version? 0.13 or something below?

On latest for me.

TheDutchCoder avatar Jul 23 '25 13:07 TheDutchCoder

Could you please consider providing a reproduction? On something like stackblitz or just .zip archive?

Norbiros avatar Jul 24 '25 18:07 Norbiros

~~Okay I think the issue is that we tried putting the openapi folder in /app, and that breaks TS.~~ ~~If you keep it in the root then it seems to work.~~

Nope, still can't find the alias...

TheDutchCoder avatar Sep 09 '25 20:09 TheDutchCoder

@schillerenrico are you still able to reproduce it?

I switched to nuxt open fetch x while you took a break and in the latest nuxt open fetch there is no such error for me. Using latest Nuxt Version 4, latest nuxt open fetch and this config:

nuxt.config.ts

  openFetch: {
    clients: {
      API_FOLDER_NAME_HERE: {
        baseURL: process.env.NUXT_API_URL,
        schema: process.env.NUXT_API_JSON,
      },
    },
    // needed to make plugins/fetch.ts work
    disableNuxtPlugin: true,
  },

package.json

"devDependencies": {
    "nuxt-open-fetch": "^0.12.0",
}

tsconfig.ts

  "compilerOptions": { "types": ["./schema/openapi.global.d.ts"] }

I'm generating my own schema from import type { components } from "#open-fetch-schemas/XXX"; to shorthand my types :)

schillerenrico avatar Sep 10 '25 06:09 schillerenrico