content: (bug): Nuxt typecheck is broken with nuxt/content@2.8.0

Environment

  • Operating System: Linux
  • Node Version: v16.20.0
  • Nuxt Version: 3.7.0
  • CLI Version: 3.7.2
  • Nitro Version: 2.6.2
  • Package Manager: npm@9.4.2
  • Builder: -
  • User Config: modules
  • Runtime Modules: @nuxt/content@2.8.0
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-jvxdxz?file=README.md

Describe the bug

With the release of @nuxt/content@2.8.0 it seems like the typecheck command for Nuxt breaks. Two main warnings/errors pop up

  • One: the @nuxtjs/mdc package, specifically in the ProseH1.vue -> ProseH6.vue files have typescript issues that bubble up when running nuxt typecheck
  • Two: ProseCode.vue seems to be resolved twice (Check the logs section for the full error logs)

In my mind there are two problems here

  1. The type issue that exists in the module which breaks typecheck for the entire project
  2. The fact that Nuxt is checking types within node_modules in the first place. Surely this is not expected behaviour

Additional context

No response

Logs

Warning logs when running nuxt dev or nuxt typecheck

 WARN  [nuxt] Two component files resolving to the same name ProseCode:                                                                                                   11:48:06 am

 - /PATH_TO_REPO/node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseCode.vue
 - /PATH_TO_REPO/node_modules/.pnpm/@nuxt+content@2.8.0_vue@3.3.4/node_modules/@nuxt/content/dist/runtime/components/Prose/ProseCode.vue

Error logs when running nuxt typecheck

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH1.vue:19:45 - error TS18048: 'headings' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h1)
                                               ~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH1.vue:19:45 - error TS18048: 'headings.anchorLinks' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h1)
                                               ~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH2.vue:19:45 - error TS18048: 'headings' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h2)
                                               ~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH2.vue:19:45 - error TS18048: 'headings.anchorLinks' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h2)
                                               ~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH3.vue:19:45 - error TS18048: 'headings' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h3)
                                               ~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH3.vue:19:45 - error TS18048: 'headings.anchorLinks' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h3)
                                               ~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH4.vue:19:45 - error TS18048: 'headings' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h4)
                                               ~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH4.vue:19:45 - error TS18048: 'headings.anchorLinks' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h4)
                                               ~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH5.vue:19:45 - error TS18048: 'headings' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h5)
                                               ~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH5.vue:19:45 - error TS18048: 'headings.anchorLinks' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h5)
                                               ~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH6.vue:19:45 - error TS18048: 'headings' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h6)
                                               ~~~~~~~~

node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH6.vue:19:45 - error TS18048: 'headings.anchorLinks' is possibly 'undefined'.

19 const generate = computed(() => props.id && headings.anchorLinks.h6)
                                               ~~~~~~~~~~~~~~~~~~~~


Found 12 errors in 6 files.

Errors  Files
     2  node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH1.vue:19
     2  node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH2.vue:19
     2  node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH3.vue:19
     2  node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH4.vue:19
     2  node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH5.vue:19
     2  node_modules/.pnpm/@nuxtjs+mdc@0.1.2/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseH6.vue:19

 ERROR  Command failed with exit code 2: vue-tsc --noEmit                                                                                                                 11:48:08 am

  at makeError (node_modules/.pnpm/nuxi@3.7.2/node_modules/nuxi/dist/chunks/index3.mjs:625:11)
  at handlePromise (node_modules/.pnpm/nuxi@3.7.2/node_modules/nuxi/dist/chunks/index3.mjs:1688:26)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async Object.run (node_modules/.pnpm/nuxi@3.7.2/node_modules/nuxi/dist/chunks/typecheck.mjs:81:7)
  at async runCommand$1 (node_modules/.pnpm/nuxi@3.7.2/node_modules/nuxi/dist/shared/nuxi.c627b411.mjs:1644:5)
  at async runCommand$1 (node_modules/.pnpm/nuxi@3.7.2/node_modules/nuxi/dist/shared/nuxi.c627b411.mjs:1638:7)
  at async runMain$1 (node_modules/.pnpm/nuxi@3.7.2/node_modules/nuxi/dist/shared/nuxi.c627b411.mjs:1756:7)



 ERROR  Command failed with exit code 2: vue-tsc --noEmit                                                                                                                 11:48:08 am

error Command failed with exit code 1.

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 20
  • Comments: 26 (10 by maintainers)

Most upvoted comments

Was this bug fixed? I received the same warning.

Snipaste_2023-09-08_21-13-35

any update ?

Hi All Finally I can confirn ProseCode and ProsePre has gone after I update nuxt to 3.7.2 The issue of slow startup is fixed too

I hope this issue not comeback again

Any other one, is the issue fixed to on latest nuxt ?

The WARN [nuxt] Two component files resolving to the same name ProseCode: 4:50:12 PM are resolved on nuxt edge via https://github.com/nuxt/nuxt/pull/22882.

I can confirm that the type errors have been fixed with v2.8.1.


The Prose override warnings have already been reported in #2262 and nuxt/nuxt#22876, and have been solved in Nuxt’s edge channel with nuxt/nuxt#22882

On edge I can still see the warning:

❯ yarn dev
yarn run v1.22.19
$ nuxt dev
Nuxt 3.7.1-28223216.aa0ea8bf with Nitro 2.6.3-28222009.2a33f1f                                            4:50:10 PM
                                                                                                          4:50:11 PM
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ℹ Using Tailwind CSS from ~/assets/css/tailwind.css                                     nuxt:tailwindcss 4:50:11 PM
ℹ Tailwind Viewer: //_tailwind/                                                         nuxt:tailwindcss 4:50:12 PM

 WARN  [nuxt] Two component files resolving to the same name ProseCode:                                   4:50:12 PM

 - /.../ui/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseCode.vue
 - /.../ui/node_modules/@nuxt/content/dist/runtime/components/Prose/ProseCode.vue


 WARN  [nuxt] Two component files resolving to the same name ProsePre:                                    4:50:12 PM

 - /.../ui/node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProsePre.vue
 - /.../ui/node_modules/@nuxt/content/dist/runtime/components/Prose/ProsePre.vue

ℹ ✨ optimized dependencies changed. reloading                                                           4:50:17 PM
ℹ ✨ new dependencies optimized: remark-reading-time                                                     4:50:18 PM
ℹ ✨ optimized dependencies changed. reloading                                                           4:50:18 PM
ℹ Vite client warmed up in 5308ms                                                                        4:50:18 PM
✔ Nitro built in 2718 ms                          

Is any update on this issue ? Btw my development experience is so bad, I dont know this related to nuxt content, tailwind, or any other thing But currently my startup time is CRAZY slow, any one experience the same thing ?

image

Just wait 3 minute for nitro built 😦

I also get it with edge-channel: https://stackblitz.com/edit/github-fu8htb?file=package.json

Maybe because both are modules and therefore have the same priority?

The effect of this PR does not change behaviour; it only suppresses logs when overriding a lower priority component directory, to keep this within a patch release. We can consider bigger possible changes in the next minor. Reference: nuxt/nuxt#22882

Alright, closing this issue now. I’ve confirmed the reported issues are no longer present as of nuxt 3.7.3 and @nuxt/content 2.8.2 Thank you to everyone who helped fix this 😄

@manniL No, as far as I can see, it is solved: https://stackblitz.com/edit/github-fu8htb-vzqfsb?file=package.json There are no warnings logged with Content v2.8.2 and Nuxt v3.7.2 anymore.

Show startup logs
~/projects/github-fu8htb-vzqfsb
❯ npm install && npm run dev

added 880 packages in 8s

226 packages are looking for funding
  run `npm fund` for details

> dev
> nuxt dev

Nuxt 3.7.3 with Nitro 2.6.3                                                                                                                                   22:46:29
                                                                                                                                                              22:46:29
 
              █▀▀▀▀▀▀▀███▀█▀█▀█▀▀▀▀██▀▀▀▀▀▀▀█
              █ █▀▀▀█ █▄█▄█▀█ ▄▀▄██ █ █▀▀▀█ █
              █ █   █ █▄ ▄█▄ ▀▄▀▄▀ ▀█ █   █ █
              █ ▀▀▀▀▀ █ ▄▀▄ █▀▄ █▀█ █ ▀▀▀▀▀ █
              █▀▀▀▀▀█▀▀▀ ▄ ▀▀▀▄▄▀█ ▄▀█▀█▀█▀██
              ██▄▀▀  ▀███ █ ▄█▀██▄▄    ▄███▄█
              █▀█ ██▀▀█▄▀▀▄ ▀▀▀█▀▄▄██▄█▄ ▀▄██
              █ ▀▄▄▄▄▀█▀ ▀▄██ ▀ ▄ ▄▄ ▄  ▀▀█▄█
              █▄▄ ▀█▄▀▀  █▄▄▀▀  ▀█ ▄▄▄█▄▀▀▄██
              █ ▄█▀▄▄▀▄▄ ▀▄▀▀█▀▄██▄█▄ ▄ █ █▄█
              █ █ █▄▀▀▀▀█▄▄▀▀█▄█▀  ▀ ▀  █▀ ▀█
              █▀▀▀▀▀▀▀█ ▀█▄█▄▀▀▄ ▄  █▀█   ▄▄█
              █ █▀▀▀█ █▀  █▄▀   ▀█▄ ▀▀▀ █▀ ██
              █ █   █ █ ▄▄▄▀▀ ▀ ▀▄▀█▀▀ ▀  ▀▄█
              █ ▀▀▀▀▀ █ █▄ ▄▀▀▄█▀█ ▄▄▄▄▀ ▀▄██
              ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 
  ➜ Network:  https://stackblitz.com/edit/github-fu8htb-vzqfsb [QR code]
  ➜ Local:    http://localhost:3000/

ℹ [nuxt] compiled plugins/server.mjs in 1202.72ms                                                                                                            22:46:37
ℹ [nuxt] compiled plugins/client.mjs in 1260.68ms                                                                                                            22:46:37
✔ Nitro built in 2086 ms                                                                                                                               nitro 22:46:45
ℹ ✨ optimized dependencies changed. reloading                                                                                                               22:46:45
ℹ Vite client warmed up in 5792ms

#2302 was one way to fix it, but the issue seems to be resolved with nuxt/nuxt#23156. So #2302 doesn’t seem to be needed anymore.


If you can share a reproduction where there are warnings with these package versions, then this issue should not be closed, of course.

FYI – Got the same on a fresh install with:

  "devDependencies": {
    "@nuxt/content": "^2.8.2",
    "nuxt": "^3.7.1"
  }

Ah, sorry. I mis-read that the issue is fixed. I’ll wait for the Edge-channel to be merged…

Thanks @nobkd for the quick turnaround.