fi3ework / vite-plugin-checker

💬 Vite plugin that provide checks of TypeScript, ESLint, vue-tsc, Stylelint and more.
https://vite-plugin-checker.netlify.app
MIT License
997 stars 87 forks source link

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' #129

Open DrJume opened 2 years ago

DrJume commented 2 years ago

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

fi3ework commented 2 years ago

Try deleting node_modules and pnpm i again. Does it work? Did you disabled hoist of pnpm in npmrc?

DrJume commented 2 years ago

I already tried that. I also didn't change the default pnpm settings.

fi3ework commented 2 years ago

Would you like to paste your package.json

DrJume commented 2 years ago

Issue was fixed with (probably) version 0.4.5 👍

olemarius commented 2 years ago

I still get this issue on 0.4.6

node:internal/event_target:916
  process.nextTick(() => { throw err; });
                           ^
Error: Cannot find module 'C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\checkers\vueTsc\typescript-vue-tsc\package.json'
Require stack:
- C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\checkers\vueTsc\prepareVueTsc.js     
- C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\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 (C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\checkers\vueTsc\prepareVueTsc.js:61:29)
    at Object.configureServer (C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\checkers\vueTsc\main.js:46:70)
    at MessagePort.<anonymous> (C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\worker.js:75:24)
    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: [
    'C:\\Git\\BlocPlatform\\Bloc\\Frontend\\Bloc.Vue\\node_modules\\.pnpm\\vite-plugin-checker@0.4.6_vite@2.9.8\\node_modules\\vite-plugin-checker\\lib\\checkers\\vueTsc\\prepareVueTsc.js',
    'C:\\Git\\BlocPlatform\\Bloc\\Frontend\\Bloc.Vue\\node_modules\\.pnpm\\vite-plugin-checker@0.4.6_vite@2.9.8\\node_modules\\vite-plugin-checker\\lib\\checkers\\vueTsc\\main.js'
  ]
}
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command npm run dev" terminated with exit code: 1.
DrJume commented 2 years ago

I still get this issue on 0.4.6

node:internal/event_target:916
  process.nextTick(() => { throw err; });
                           ^
Error: Cannot find module 'C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\checkers\vueTsc\typescript-vue-tsc\package.json'
Require stack:
- C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\checkers\vueTsc\prepareVueTsc.js     
- C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\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 (C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\checkers\vueTsc\prepareVueTsc.js:61:29)
    at Object.configureServer (C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\checkers\vueTsc\main.js:46:70)
    at MessagePort.<anonymous> (C:\Git\BlocPlatform\Bloc\Frontend\Bloc.Vue\node_modules\.pnpm\vite-plugin-checker@0.4.6_vite@2.9.8\node_modules\vite-plugin-checker\lib\worker.js:75:24)
    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: [
    'C:\\Git\\BlocPlatform\\Bloc\\Frontend\\Bloc.Vue\\node_modules\\.pnpm\\vite-plugin-checker@0.4.6_vite@2.9.8\\node_modules\\vite-plugin-checker\\lib\\checkers\\vueTsc\\prepareVueTsc.js',
    'C:\\Git\\BlocPlatform\\Bloc\\Frontend\\Bloc.Vue\\node_modules\\.pnpm\\vite-plugin-checker@0.4.6_vite@2.9.8\\node_modules\\vite-plugin-checker\\lib\\checkers\\vueTsc\\main.js'
  ]
}
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command npm run dev" terminated with exit code: 1.

Me too...

DrJume commented 2 years ago

I could fix this issue by running pnpm store prune or manually deleting the whole pnpm store in pnpm store path and reinstalling the dependencies with pnpm install.

DrJume commented 2 years ago

It's very weird, because 1 hour ago everything was ok.

I think a pnpm install in a different repo somehow deleted the package.json inside typescript-vue-tsc in my local pnpm store... So it seems to be an issue with pnpm?

Miofly commented 2 years ago

Has this problem been solved

Miofly commented 2 years ago

Has this problem been solved

hello,Has this problem been solved

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a bug report, please provide a minimal re-production repository or use path to reproduce. Thank you for your contributions.

fristys commented 2 years ago

Can confirm this is still an issue

groundfloorwebb commented 2 years ago

I can also confirm this is still an issue. I made a fresh project with create-vue to test out this plugin, enabled the vueTsc option and immediately got the same error as everyone else.

Vite config

import { fileURLToPath, URL } from 'node:url';

import vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';
import checker from 'vite-plugin-checker';

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        checker({
            vueTsc: true,
        }),
        vue(),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url)),
        },
    },
});

Stack trace

node:internal/event_target:964
  process.nextTick(() => { throw err; });
                           ^
Error: Cannot find module '/Users/benwebb/code/create-vue-test/node_modules/vite-plugin-checker/lib/checkers/vueTsc/typescript-vue-tsc/package.json'
Require stack:
- /Users/benwebb/code/create-vue-test/node_modules/vite-plugin-checker/lib/checkers/vueTsc/prepareVueTsc.js
- /Users/benwebb/code/create-vue-test/node_modules/vite-plugin-checker/lib/checkers/vueTsc/main.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at prepareVueTsc (/Users/benwebb/code/create-vue-test/node_modules/vite-plugin-checker/lib/checkers/vueTsc/prepareVueTsc.js:61:29)
    at Object.configureServer (/Users/benwebb/code/create-vue-test/node_modules/vite-plugin-checker/lib/checkers/vueTsc/main.js:46:70)
    at MessagePort.<anonymous> (/Users/benwebb/code/create-vue-test/node_modules/vite-plugin-checker/lib/worker.js:75:24)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:689:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
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:689:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
    at [kOnExit] (node:internal/worker:268:5)
    at Worker.<computed>.onexit (node:internal/worker:199:20) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/benwebb/code/create-vue-test/node_modules/vite-plugin-checker/lib/checkers/vueTsc/prepareVueTsc.js',
    '/Users/benwebb/code/create-vue-test/node_modules/vite-plugin-checker/lib/checkers/vueTsc/main.js'
  ]
}
groundfloorwebb commented 2 years ago

Deleting node modules and reinstalling as described by @DrJume does seem to resolve the issue. Strange.

DrJume commented 2 years ago

I think it basically fails to put the package.json in the directory. A first install worked, maybe the (pnpm) upgrade sometimes deletes the package.json?

fi3ework commented 2 years ago

Does this issue still exists after 0.5.0? Although I'm not very clearly what cause the issue, but I added a try catch statement to prevent this.

https://github.com/fi3ework/vite-plugin-checker/blob/140f96c3d24f70e118e8397fc23aa7e41e01ee91/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts#L53-L66

fi3ework commented 2 years ago

I think it should be fixed in 0.5.0 from latest response in https://github.com/fi3ework/vite-plugin-checker/issues/137

z1m1n commented 2 years ago

I think it should be fixed in 0.5.0 from latest response in #137

Still getting similar error in 0.5.1

Error: EROFS: read-only filesystem, mkdir '/node_modules/vite-plugin-checker/dist/cjs/checkers/vueTsc/typescript-vue-tsc'

IlCallo commented 1 year ago

Same here on 0.5.2 when using stylelint

node:internal/event_target:969
  process.nextTick(() => { throw err; });
                           ^
TypeError [Error]: (0 , import_options.default) is not a function
    at Object.configureServer (/.../node_modules/.pnpm/vite-plugin-checker@0.5.2/node_modules/vite-plugin-checker/dist/cjs/checkers/stylelint/main.js:58:60)
    at MessagePort.<anonymous> (/.../node_modules/.pnpm/vite-plugin-checker@0.5.2/node_modules/vite-plugin-checker/dist/cjs/worker.js:80:26)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:694: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:290:10)
    at Worker.[kOnMessage] (node:internal/worker:301:37)
    at MessagePort.<anonymous> (node:internal/worker:202:57)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:694:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)

The mentioned import refers to options.js, but that file does exist, so it's the problem isn't clear

fi3ework commented 1 year ago

@IlCallo This seems like not the same issue in this thread but related to https://github.com/fi3ework/vite-plugin-checker/issues/184 as the default export is not found in CJS mode. Let's track in that issue and would like to provide a minimal re-pro?

eleven-net-cn commented 1 year ago
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

IlCallo commented 1 year ago

This seems like not the same issue in this thread but related to https://github.com/fi3ework/vite-plugin-checker/issues/184

I ignored that one since I'm using Vite 2, while that's about Vite 3 I'm gonna create a repro, I think the problem may related to the monorepo structure of my project

daniele-orlando commented 1 year ago
VITE v4.0.4  ready in 633 ms

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

node:internal/event_target:1013
  process.nextTick(() => { throw err; });
                           ^
Error: start < 0
    at createTextSpan (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:12547:19)
    at Object.createTextSpanFromBounds (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:12556:16)
    at getErrorSpanForNode (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:15597:19)
    at Object.createDiagnosticForNodeFromMessageChain (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:15462:20)
    at resolveExternalModule (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:52379:52)
    at resolveExternalModuleNameWorker (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:52301:19)
    at resolveExternalModuleName (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:52296:20)
    at getSymbolAtLocation (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:88409:32)
    at Object.getSymbolAtLocation (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:49394:31)
    at getReferencedFilesFromImportLiteral (/Users/dan/example/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/typescript.js:122348:34)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:300:10)
    at [kOnMessage] (node:internal/worker:311:37)
    at MessagePort.<anonymous> (node:internal/worker:207:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:738:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)

Node.js v19.3.0
isabolic commented 1 year ago

works for me when you add pnpm add vue-tsc@latest typescript vite-plugin-checker -D (monorepo case)

fi3ework commented 1 year ago

@isabolic Which re-produce method or solution works for you? 🤔

isabolic commented 1 year ago

@fi3ework I had a exact error, so I run

now pnpm dev has no errors

fi3ework commented 1 year ago

@isabolic Which version of the plugin you're using?

isabolic commented 1 year ago

@fi3ework issue still present after double check... sorry about that :)

isabolic commented 1 year ago

Error: EEXIST: file already exists, mkdir

isabolic commented 1 year ago

I think this is monorepo case, if i go intopackages/ui-components and run pnpm dev/vite dev and go back to root repo directory and after that I run pnpm dev works fine... But after you add new package or update to latest the same error appears..

kevinvalk commented 1 year ago

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?

Miofly commented 1 year ago

same error in pnpm workspace image

Montralis commented 1 year ago

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

gaojizu commented 4 months ago

issue is exists till today i don`t know how to handle it i want know how to fix.
image

Alixhan commented 3 months ago

vite-plugin-checker version 0.7.2, I got the error

  VITE v5.3.3 

error when starting dev server:
Error: Cannot find module 'vue-tsc/package.json'
Require stack:
- E:\my-workspace\xh-bms\xh-admin-frontend\node_modules\.pnpm\vite-plugin-checker@0.7.2_eslint@8.57.0_optionator@0.9.4_typescript@5.4.5_vite@5.3.3_@types+n_g2k6lq7lhxwlgneuifsug7ynae\node_modules\vite-plugin-checker\dist\esm\checkers\vueTsc\prepareVueTsc.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1186:15)
    at Function.resolve (node:internal/modules/helpers:133:19)
    at file:///E:/my-workspace/xh-bms/xh-admin-frontend/node_modules/.pnpm/vite-plugin-checker@0.7.2_eslint@8.57.0_optionator@0.9.4_typescript@5.4.5_vite@5.3.3_@types+n_g2k6lq7lhxwlgneuifsug7ynae/node_modules/vite-plugin-checker/dist/esm/checkers/vueTsc/prepareVueTsc.js:10:36
    at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:475:24)
    at async createCheckers (file:///E:/my-workspace/xh-bms/xh-admin-frontend/node_modules/.pnpm/vite-plugin-checker@0.7.2_eslint@8.57.0_optionator@0.9.4_typescript@5.4.5_vite@5.3.3_@types+n_g2k6lq7lhxwlgneuifsug7ynae/node_modules/vite-plugin-checker/dist/esm/main.js:31:37)
    at async config (file:///E:/my-workspace/xh-bms/xh-admin-frontend/node_modules/.pnpm/vite-plugin-checker@0.7.2_eslint@8.57.0_optionator@0.9.4_typescript@5.4.5_vite@5.3.3_@types+n_g2k6lq7lhxwlgneuifsug7ynae/node_modules/vite-plugin-checker/dist/esm/main.js:64:18)
    at async runConfigHook (file:///E:/my-workspace/xh-bms/xh-admin-frontend/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10_sass@1.77.8_terser@5.31.2/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:67013:19)
    at async resolveConfig (file:///E:/my-workspace/xh-bms/xh-admin-frontend/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10_sass@1.77.8_terser@5.31.2/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:66464:12)
    at async _createServer (file:///E:/my-workspace/xh-bms/xh-admin-frontend/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10_sass@1.77.8_terser@5.31.2/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:63048:18)
 ELIFECYCLE  Command failed with exit code 1.

18:06:11 [vite] server restart failed
fi3ework commented 3 months ago

@Alixhan Did you installed vue-tsc alongside?

Alixhan commented 3 months ago

@fi3ework No, I got another error after installing vue-tsc.

vite --mode development

  VITE v5.3.3  ready in 1381 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://2.0.0.1:5173/
  ➜  Network: http://172.17.112.1:5173/
  ➜  Network: http://192.168.1.134:5173/
  ➜  press h + enter to show help

node:internal/event_target:1090
  process.nextTick(() => { throw err; });
                           ^
Error [ERR_REQUIRE_ESM]: require() of ES Module E:\my-workspace\xh-bms\xh-admin-frontend\node_modules\.pnpm\vite-plugin-checker@0.7.2_eslint@8.57.0_optionator@0.9.4_typescript@5.4.5_vite@5.3.3_@types+n_uhgroegrsorsy4x5zhojfsa6s4\nod
e_modules\vite-plugin-checker\dist\esm\checkers\vueTsc\typescript-vue-tsc\lib\typescript.js from E:\my-workspace\xh-bms\xh-admin-frontend\node_modules\.pnpm\vite-plugin-checker@0.7.2_eslint@8.57.0_optionator@0.9.4_typescript@5.4.5_vite@5.3.3_@types+n_uhgroegrsorsy4x5zhojfsa6s4\node_modules\vite-plugin-checker\dist\esm\checkers\vueTsc\main.js not supported.
typescript.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename typescript.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in E:\my-workspace\xh-bms\xh-admin-fr
ontend\node_modules\.pnpm\vite-plugin-checker@0.7.2_eslint@8.57.0_optionator@0.9.4_typescript@5.4.5_vite@5.3.3_@types+n_uhgroegrsorsy4x5zhojfsa6s4\node_modules\vite-plugin-checker\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at Object.configureServer (file:///E:/my-workspace/xh-bms/xh-admin-frontend/node_modules/.pnpm/vite-plugin-checker@0.7.2_eslint@8.57.0_optionator@0.9.4_typescript@5.4.5_vite@5.3.3_@types+n_uhgroegrsorsy4x5zhojfsa6s4/node_modules/vite-plugin-checker/dist/esm/checkers/vueTsc/main.js:36:21) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v22.2.0
 ELIFECYCLE  Command failed with exit code 1.
fi3ework commented 3 months ago

@Alixhan You need to change your project to type: "module".

Alixhan commented 3 months ago

image @fi3ework Yes, It is

fi3ework commented 3 months ago

@Alixhan Could you provide a minimal reproduction

Alixhan commented 3 months ago

@Alixhan Could you provide a minimal reproduction

Thank you. I'll provide it later.

Alixhan commented 3 months ago

@fi3ework The demo create by latest vue . https://stackblitz.com/edit/vitejs-vite-pqfh12?file=package.json,vite.config.ts&terminal=dev

fi3ework commented 3 months ago

Bumping typescript to 5.5.0 could fix the issue, I think vue-tsc requires a higher minimal version of ts now. But vue-tsc works fine with ts 5.4.0. cc @so1ve Any idea of this issue 🤔?

so1ve commented 3 months ago

Sorry, I don't know why typescript can't be required...