2020-10-20-esbuild cannot transform main.ts

在执行完npm install github-markdown-css后,运行npm run dev报错如下:

PS C:\Users\dell\Desktop\gulu-ui-1> npm run dev

> [email protected] dev C:\Users\dell\Desktop\gulu-ui-1
> vite

vite v1.0.0-rc.4
C:\Users\dell\Desktop\gulu-ui-1 vue-router
[vite] cannot resolve entry for dependency vue-router.
[vite] Optimizable dependencies detected:
vue

  Dev server running at:
  > Network:  http://192.168.140.1:3000/
  > Network:  http://192.168.133.1:3000/
  > Network:  http://192.168.1.2:3000/
  > Local:    http://localhost:3000/

[vite] error while transforming C:\Users\dell\Desktop\gulu-ui-1\src\main.ts with esbuild:
Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:156:25)
    at writeGeneric (internal/stream_base_commons.js:147:3)
    at Socket._writeGeneric (net.js:788:11)
    at Socket._write (net.js:800:8)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Object.writeToStdin (C:\Users\dell\Desktop\gulu-ui-1\node_modules\esbuild\lib\main.js:550:19)
    at sendRequest (C:\Users\dell\Desktop\gulu-ui-1\node_modules\esbuild\lib\main.js:340:13)
    at start (C:\Users\dell\Desktop\gulu-ui-1\node_modules\esbuild\lib\main.js:399:11) {
  errno: 'EPIPE',
  code: 'EPIPE',
  syscall: 'write'
}
events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\dell\Desktop\gulu-ui-1\node_modules\esbuild\esbuild.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\dell\\Desktop\\gulu-ui-1\\node_modules\\esbuild\\esbuild.exe',
  path: 'C:\\Users\\dell\\Desktop\\gulu-ui-1\\node_modules\\esbuild\\esbuild.exe',
  spawnargs: [ '--service' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `vite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dell\AppData\Roaming\npm-cache\_logs\2020-10-18T09_46_24_735Z-debug.log
PS C:\Users\dell\Desktop\gulu-ui-1>

我左搜右搜,终于搜到了解决办法:

Delete your package-lock.json file and node_modules folder. Then do npm cache clean
npm cache clean --force
do npm install
again and run

附上原文链接:https://stackoverflow.com/questions/57605441/error-this-is-probably-not-a-problem-with-npm-there-is-likely-additional-loggi
虽然这样做能解决问题,但是我并不明白其中的道理,所以还有其他备选答案。
附上链接以备以后看:https://github.com/vitejs/vite/issues/62
https://github.com/evanw/esbuild/commit/562a849d526c213549282b830a224e68b5327c0e

你可能感兴趣的:(2020-10-20-esbuild cannot transform main.ts)