nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

Typescript typecheck emits lots of type errors when running dev server

Open danielrentz opened this issue 1 month ago • 17 comments

Environment


  • Operating System: Windows_NT
  • Node Version: v22.19.0
  • Nuxt Version: 4.2.0
  • CLI Version: 3.29.3
  • Nitro Version: 2.12.9
  • Package Manager: [email protected]
  • Builder: -
  • User Config: compatibilityDate, devtools, typescript
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-qcconkvv?file=nuxt.config.ts

pnpm run dev triggers the problem.

Describe the bug

Following the instructions here: https://nuxt.com/docs/4.x/guide/concepts/typescript#type-checking

Starting the dev server logs lots of type errors, such as

[vue-tsc] Cannot find name 'Boolean'. Did you mean 'GLboolean'?
[vue-tsc] Cannot find global type 'CallableFunction'.
[vue-tsc] Cannot find global type 'IArguments'.
[vue-tsc] Cannot find global type 'NewableFunction'.
[vue-tsc] Cannot find global type 'Number'.
[vue-tsc] Cannot find global type 'Object'.
[vue-tsc] File 'test/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib/lib.dom.d.ts' not found. The file is in the program because: Library 'lib.dom.d.ts' specified in compilerOptions

Log can be found in the shell and in the browser (vite-plugin-checker overlay).

Additional context

No response

Logs


danielrentz avatar Nov 03 '25 10:11 danielrentz

Hello, the reproduction looks like a starter project. Could you check it, please? Can you see the error in stackblitz too?

cernymatej avatar Nov 03 '25 12:11 cernymatej

Would you be able to provide a minimal reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

Please use a template below to create a minimal reproduction

Open v4 in Stackblitz Open v3 in Stackblitz

Open v4 in CodeSandbox Open v3 in CodeSandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

github-actions[bot] avatar Nov 03 '25 12:11 github-actions[bot]

@cernymatej It is the starter project linked from the Issue creation template, but slightly modified afterwards. The only changes are:

  • npm install typescript tsc-vue
  • add typescript: { typeCheck: true } in nuxt.config.ts

After opening the repro page, just wait for package install and dev server startup, and have a look into the shell and the browser panel. Both show the mentioned errors. I just checked again in a new fresh private browser window.

danielrentz avatar Nov 03 '25 12:11 danielrentz

sorry about that, I can see the errors now. for some reason, it didn't show them when I checked the first time even though the nuxt app was running 👀

cernymatej avatar Nov 03 '25 12:11 cernymatej

Looks like a bug in vue-tsc v3.1.3. Could you please check if it works for you when the version is pinned to 3.1.2 ? https://stackblitz.com/edit/github-qcconkvv-vaents6a?file=package.json

If so, would you mind opening an issue there?

cernymatej avatar Nov 03 '25 12:11 cernymatej

@cernymatej I tried 3.1.2, 3.1.1, 3.1.0, and 3.0.0. All show the same error.

The error cascade starts with

 ERROR  [uncaughtException] Unhandled error. ({                                                                                                              14:06:10
  code: 'ENOTEMPTY',
  errno: -39,
  path: '/home/projects/github-qcconkvv-vaents6a/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib',
  syscall: 'rmdir',
  message: "ENOTEMPTY: directory not empty, rmdir '/home/projects/github-qcconkvv-vaents6a/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib'",
  stack: "ENOTEMPTY: directory not empty, rmdir '/home/projects/github-qcconkvv-vaents6a/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib'"
})

Seems that someone wants to write into the vite-plugin-checker package when starting the dev server.

In our project using Yarn4 the error looks similarly:

 ERROR  [uncaughtException] ENOTEMPTY: directory not empty, rmdir '<our_project>\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc\lib'

After deleting node_modules and reinstalling all packages, the "node_modules/vite-plugin-checker/dist/checkers/vueTsc" directory contains only the files

languagePlugins.cjs
main.{d.ts,js,js.map}
prepareVueTsc.{d.ts,js,js.map}

After starting the dev server, this directory contains a new "typescript-vue-tsc" directory with a non-empty "lib" subdir containing a few TS lib files, but e.g. without "lib.dom.d.ts" mentioned in the error log.

I have also tried downgrading "vite-plugin-checker" to 0.10.2 and 0.10.0 (current version is 0.11.0), but the problem persists.

danielrentz avatar Nov 03 '25 13:11 danielrentz

PS: It seems to be Nuxt itself, I downgraded it to 4.1.3 and the problem is gone (all other packages up-to-date).

danielrentz avatar Nov 03 '25 13:11 danielrentz

same issue at Nuxt 4.2.1. downgrading to 4.1.3 also helps.

Ethosa avatar Nov 07 '25 04:11 Ethosa

for me, on first run I get:

[16:23:05]  ERROR  [uncaughtException] ENOENT: no such file or directory, chmod '/private/tmp/github-qcconkvv/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected]__v_gsxv4g326waugu6yfixcyhs5hq/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib/typescript.js'

    at async chmod (node:internal/fs/promises:1087:10)
    at async copyDir (node:internal/fs/cp/cp:321:19)
    at async mkDirAndCopy (node:internal/fs/cp/cp:310:3)
    at async copyDir (node:internal/fs/cp/cp:321:19)
    at async prepareVueTsc (node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected]__v_gsxv4g326waugu6yfixcyhs5hq/node_modules/vite-plugin-checker/dist/checkers/vueTsc/prepareVueTsc.js:44:5)
    at async Object.configureServer (node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected]__v_gsxv4g326waugu6yfixcyhs5hq/node_modules/vite-plugin-checker/dist/checkers/vueTsc/main.js:35:31)

and on subsequent runs it doesn't show any errors any more. (and in both cases, it shows 0 errors) maybe it only reproduces on windows? 🤔

danielroe avatar Nov 07 '25 16:11 danielroe

@danielroe StackBlitz runs on Linux :) But ... I cannot reproduce it anymore as well, neither on StackBlitz nor locally. The error may have been caused by some indirect sub dependency of Nuxt. StackBlitz always installs from scratch without lock file, and locally I have upgraded again after downgrading to 4.1.3. So.... everything fine now

danielrentz avatar Nov 08 '25 21:11 danielrentz

@danielroe Sorry to bother again, but I am afraid the bug is real, but appears only sometimes on StackBlitz. To be sure, I tried the StackBlitz repro on Windows 11 and Debian 12. I observed the following results in no specific order when reloading the browser tab repeatedly:

  • everything is fine, dev server starts up normally
  • the ENOENT error you observed above, afterwards no type errors, but preview app remains empty.
  • the ENOENT error, and afterwards lots of type errors as described initially (see below), but without Nuxt error overlay in the preview app.
  • same, but with Nuxt error overlay in the preview app.

Then I retried with my own project, and the problem returned after deleting node_modules and reinstalling. On Windows, quite always with the full set of errors, on Debian with something different like ENOEMPTY directory not empty followed by [uncaughtException] require is not defined

I retried with Nuxt 4.1.3 and everything is still fine. Then I added a few console.logs into the function "prepareVueTsc" in the file node_modules/vite-plugin-checker/dist/checkers/vueTsc/prepareVueTsc.js which appears sometimes in the stacks. This function aims to copy the TS lib files from node_modeules/typescript to node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc if this directory is missing.

And what I see is that this function is called twice from Nuxt 4.2.1 but once from Nuxt 4.1.3.

The output from 4.1.3 is (indented logs are mine)

√ Vite client built in 76ms
  >>> prepareVueTsc()
  rm(C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc)
  mkdir(C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc)
  cp(C:\...\node_modules\typescript, C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc)
√ Vite server built in 234ms
  writeFile(C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc\vue-tsc-resolve-path)
  overrideTscJs()
  <<< prepareVueTsc()
√ Nuxt Nitro server built in 2272ms
i Vite client warmed up in 3ms
i Vite server warmed up in 57ms

The output from 4.2.1 is

√ Vite client built in 72ms
  >>> prepareVueTsc()
  rm(C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc)
  mkdir(C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc)
  cp(C:\...\node_modules\typescript, C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc)
√ Vite server built in 81ms
  >>> prepareVueTsc()
  rm(C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc)
 ERROR  [uncaughtException] ENOTEMPTY: directory not empty, rmdir 'C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc\lib'
  writeFile(C:\...\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc\vue-tsc-resolve-path)
  overrideTscJs()
  <<< prepareVueTsc() END
√ Nuxt Nitro server built in 1643ms
i Vite server warmed up in 1ms
i Vite client warmed up in 4ms
 ERROR(vue-tsc)  Cannot find name 'Boolean'. Did you mean 'GLboolean'?
 ERROR(vue-tsc)  Cannot find global type 'CallableFunction'.
... more errors ...
 ERROR(vue-tsc)  File 'C:/.../node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib/lib.dom.d.ts' not found.
  The file is in the program because:
    Library 'lib.dom.d.ts' specified in compilerOptions
... more errors ...

So the second rm() interferes with the first cp() and throws. Same on Linux. The only difference seems to be how Windows and Linux handle the concurring file access.

danielrentz avatar Nov 10 '25 19:11 danielrentz

I'm having the same issues on a project when starting Nuxt in dev mode.

Even though the typecheck in the console runs without errors.

nuxt.config:

typescript: {
  typeCheck: true,
  tsConfig: { compilerOptions: { strict: true } },
  nodeTsConfig: { compilerOptions: { strict: true } },
},

package.json:

"typescript": "5.9.3",    
"vue-tsc": "3.1.2",    
"nuxt": "4.2.0"
Image

wokalek avatar Nov 12 '25 07:11 wokalek

Had it too after upgrading to Nuxt 4.2.1, in WSL2 👀

BaptisteCrouzet avatar Nov 12 '25 19:11 BaptisteCrouzet

Same issue in WSL2 when running npm run dev, with

  • "vue-tsc": "^3.1.2" (same on 3.1.4)
  • "nuxt": "^4.2.1" (had it on 4.1.3 too)
[12:26:09]  ERROR  [uncaughtException] ENOTEMPTY: directory not empty, rmdir 'private\node_modules\@nuxt\vite-builder\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc\lib'

[12:26:09]  ERROR  [uncaughtException] Cannot find module 'private\node_modules\@nuxt\vite-builder\node_modules\vite-plugin-checker\dist\checkers\vueTsc\typescript-vue-tsc\lib\typescript.js'
Require stack:
- private\node_modules\@nuxt\vite-builder\node_modules\vite-plugin-checker\dist\checkers\vueTsc\prepareVueTsc.js

    at Function._resolveFilename (node:internal/modules/cjs/loader:1244:15)
    at Function.resolve (node:internal/modules/helpers:146:19)

Cry0nicS avatar Nov 19 '25 11:11 Cry0nicS

No offense, but I think it's not needed to add more "me too" comments here. Please subscribe to the issue to get notified when a fix is available.

danielrentz avatar Nov 19 '25 11:11 danielrentz

I hit this problem when I use Nuxt within a monorepo architecture (using pnpm workspace). Downgrading to 4.1.3 is removing the warning.

[log] [nuxi] Working directory: /app
[log] [nuxi] Nuxt project info: 

------------------------------
- Operating System: `Linux`
- Node Version:     `v24.11.1`
- Nuxt Version:     `4.1.3`
- CLI Version:      `3.30.0`
- Nitro Version:    `2.12.9`
- Package Manager:  `[email protected]`
- Builder:          `-`
- User Config:      `app`, `compatibilityDate`, `devtools`, `modules`, `icon`, `i18n`, `runtimeConfig`, `typescript`, `nitro`, `css`, `components`
- Runtime Modules:  `@nuxt/[email protected]`, `@nuxt/test-utils/[email protected]`, `@nuxt/[email protected]`, `@nuxtjs/[email protected]`, `@pinia/[email protected]`, `@compodium/[email protected]`
- Build Modules:    `-`

edimitchel avatar Nov 28 '25 15:11 edimitchel