vite 启动项目报错

vite2下载后npm 启动报错

背景:

npm = 7.14.0

node.js = 16.0.0

 

报错信息如下:

up to date in 1s
PS D:\webdemo\vite\vite-project> npm run dev

> dev
> vite

node:events:342
throw er; // Unhandled 'error' event
^
Error: spawn D:\webdemo\vite\vite-project\node_modules\esbuild\esbuild.exe ENOENT
at onErrorNT (node:internal/child_process:480:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
at onErrorNT (node:internal/child_process:480:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn D:\\webdemo\\vite\\vite-project\\node_modules\\esbuild\\esbuild.exe',
path: 'D:\\webdemo\\vite\\vite-project\\node_modules\\esbuild\\esbuild.exe',
spawnargs: [ '--service=0.12.12', '--ping' ]
}

 

查找原因:

通过github查阅vite仓库的相关issue【https://github.com/vitejs/vite/issues/1580】,尤大也很明确的指出这个是esbuild的BUG

解决方法:手动执行

node node_modules/esbuild/install.js

参考:vite安装vue项目报错(Error: esbuild: Failed to install correctly)_starsion-CSDN博客

posted @ 2021-06-29 20:40  Mir.zhao  阅读(3264)  评论(3编辑  收藏  举报