vite-plugin-checker: Error: Cannot find module '/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/checkers/vueTsc/typescript-vue-tsc/package.json'

Describe the bug

When enabling vueTsc inside vite.config.ts by setting vueTsc: true, this error appears when running vite in dev-mode.

It appears, that a package.json is missing inside node_modules/vite-plugin-checker/lib/checkers/vueTsc/typescript-vue-tsc/

The issue was fixed by downgrading to v0.4.3

Reproduction

  1. Install vite-plugin-checker with pnpm
  2. set vueTsc: true inside vite.config.js
  3. run vite

Expected behavior

It should run without error.

System Info

System:
    OS: macOS 12.3
    CPU: (8) arm64 Apple M1
    Memory: 166.08 MB / 16.00 GB
    Shell: 5.8.1 - /opt/homebrew/bin/zsh
Binaries:
    Node: 16.14.0 - /usr/local/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 8.5.5 - /usr/local/bin/npm
Browsers:
    Chrome: 99.0.4844.84
    Safari: 15.4
npmPackages:
    vite-plugin-checker: 0.4.4 => 0.4.4

Additional context

node:internal/event_target:916
  process.nextTick(() => { throw err; });
                           ^
Error: Cannot find module '<projectDir>/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/checkers/vueTsc/typescript-vue-tsc/package.json'
Require stack:
- <projectDir>/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/checkers/vueTsc/prepareVueTsc.js
- <projectDir>/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/checkers/vueTsc/main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at prepareVueTsc (<projectDir>/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/checkers/vueTsc/prepareVueTsc.js:44:33)
    at Object.configureServer (<projectDir>/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/checkers/vueTsc/main.js:27:71)
    at MessagePort.<anonymous> (<projectDir>/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/worker.js:56:36)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:647:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)
Emitted 'error' event on Worker instance at:
    at Worker.[kOnErrorMessage] (node:internal/worker:289:10)
    at Worker.[kOnMessage] (node:internal/worker:300:37)
    at MessagePort.<anonymous> (node:internal/worker:201:57)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:647:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)
    at Worker.[kOnExit] (node:internal/worker:267:5)
    at Worker.<computed>.onexit (node:internal/worker:198:20) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '<projectDir>/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/checkers/vueTsc/prepareVueTsc.js',
    '<projectDir>/node_modules/.pnpm/vite-plugin-checker@0.4.4_vite@2.8.6/node_modules/vite-plugin-checker/lib/checkers/vueTsc/main.js'
  ]
}

Validations

  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 33 (7 by maintainers)

Most upvoted comments

Got the same here in v0.4…8. Any update on this?

Just chiming in, I just faced this problem when I upgraded to TypeScript 5.0

vite

  VITE v4.2.0  ready in 285 ms

  ➜  Local:   http://localhost:8000/
  ➜  Network: http://192.168.8.149:8000/
  ➜  Network: http://192.168.2.1:8000/
  ➜  press h to show help

node:internal/event_target:1010
  process.nextTick(() => { throw err; });
                           ^
UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Search string not found: "ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);"".
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:290:10)
    at [kOnMessage] (node:internal/worker:301:37)
    at MessagePort.<anonymous> (node:internal/worker:202:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:735:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28) {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v18.15.0

To me it seems that there is a race condition for the prepareVueTsc method. As far as I can see, that method prepares/creates the directory node_modules/vite-plugin-checker/dist/cjs/checkers/vueTsc/typescript-vue-tsc. However, vite/the checker was already started before the typescript-vue-tsc exists.

That also explains why sometimes simple reruns or removal of node_modules fixes this issue.

@fi3ework does that make any sense?

image

version: vite-plugin-checker@0.5.1 yarn v1.22.19 vite v3

When I install a new package, the folder of dist/cjs/checkers/vueTsc/typescript-vue-tsc will be removed automatically (the same as dist/esm/...), and then dev error.

And, retry to run start, the folder will be created again.

I tried to find the reason but couldn’t find it.

Error logs:

ERROR(vue-tsc)  File '/.../node_modules/vite-plugin-checker/dist/cjs/checkers/vueTsc/typescript-vue-tsc/lib/lib.dom.d.ts' not found.

@fi3ework

Has this problem been solved

hello,Has this problem been solved