nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

Getting typescript error "module '@nuxt/schema' cannot be found" when extending layer template

Open DawidKopys opened this issue 2 years ago • 3 comments

Environment

app:

- Operating System: `Darwin`
- Node Version:     `v18.16.0`
- Nuxt Version:     `3.6.5`
- Nitro Version:    `2.5.2`
- Package Manager:  `[email protected]`
- Builder:          `vite`
- User Config:      `extends`, `typescript`, `devtools`
- Runtime Modules:  `-`
- Build Modules:    `-`

nuxt-layer:

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

Reproduction

  1. clone repo https://github.com/DawidKopys/nuxt-schema-error-repro
  2. run npm i in nuxt-layer directory
  3. run npm i in app directory
  4. run npx nuxi typecheck / npm run dev / npx vue-tsc --noEmit inside app directory. You should get below error:
../nuxt-layer/app.config.ts:7:16 - error TS2664: Invalid module name in augmentation, module '@nuxt/schema' cannot be found.

7 declare module '@nuxt/schema' {
                 ~~~~~~~~~~~~~~


Found 1 error in ../nuxt-layer/app.config.ts:7

Describe the bug

  • the app directory was created by running npx nuxi@latest init app from the docs
  • the nuxt-layer directory was created with nuxt layer template - by running npx nuxi init --template layer nuxt-layer command from the docs
  • type checking was enabled in both directories by simply running npm install --save-dev typescript vue-tsc and turning type checking inside nuxt.config.ts for both directories

So, basically, I have just used the starters for app and layer, turned type checking for them, and I am getting this ts error straight away.

This error is very confusing to me as using @nuxt/schema was a solution to my previous (similar) issue and it works just fine if I use it in the repo linked in the issue - https://github.com/DawidKopys/nuxt-layers. But for some reason it doesn't work in above simple setup.

Additional context

Using @nuxt/schema was a solution to my previous (similar) issue and it works just fine if I use it in the repo linked in the issue - https://github.com/DawidKopys/nuxt-layers. But for some reason it doesn't work in above simple setup.

Logs

No response

DawidKopys avatar Aug 18 '23 14:08 DawidKopys

might help:

  • https://github.com/nuxt/cli/pull/264

at least I hope so :pray:

dargmuesli avatar Oct 27 '23 10:10 dargmuesli

Somehow adding import "nuxt/schema" on top worked for me

BruhJerem avatar Nov 01 '23 10:11 BruhJerem

Somehow adding import "nuxt/schema" on top worked for me

The result of same import for me is broken DevTools and vite:

2024-02-08 16 40 18

VictorKrasnov avatar Feb 08 '24 13:02 VictorKrasnov

This should be resolved in the latest version of Nuxt with https://github.com/nuxt/nuxt/pull/26158. Let me know if not and I'll happily reopen 🙏

danielroe avatar Jun 30 '24 11:06 danielroe