构建好vite项目,并且npm install之后执行npm run dev,出现以下错误
events.js:287
throw er; // Unhandled 'error' event
^Error: spawn xxxxxx\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 xxxxxx\\node_modules\\esbuild\\esbuild.exe',
path: 'xxxxxx\\node_modules\\esbuild\\esbuild.exe',
spawnargs: [ '--service=0.11.23', '--ping' ]
}
解决方法:
进入项目目录,执行:
node ./node_modules/esbuild/install.js