vite vue项目 运行时 \esbuild\esbuild.exe 缺失 错误码 errno: -4058, code: ‘ENOENT‘,

vite vue项目运行 npm run dev 报错某个模块启动文件丢失信息

D:\PengYe_code\2\vite-vue3-admin>npm run dev

> [email protected] dev
> vite

node:events:504
      throw er; // Unhandled 'error' event
      ^

Error: spawn D:\PengYe_code\2\vite-vue3-admin\node_modules\vite-plugin-mock\node_modules\esbuild\esbuild.exe ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn D:\\PengYe_code\\2\\vite-vue3-admin\\node_modules\\vite-plugin-mock\\node_modules\\esbuild\\esbuild.exe',
  path: 'D:\\PengYe_code\\2\\vite-vue3-admin\\node_modules\\vite-plugin-mock\\node_modules\\esbuild\\esbuild.exe',
  spawnargs: [ '--service=0.11.3', '--ping' ]
}

vite vue项目 运行时 \esbuild\esbuild.exe 缺失 错误码 errno: -4058, code: ‘ENOENT‘,_第1张图片

原因解析

因为 npm install 加载依赖包时 模块vite-plugin-mock\node_modules\esbuild\esbuild.exe 该esbuild.exe文件没有拉取到或者没有生成,缺失启动文件造成的运行失败

解决方案 (用node命令生成启动文件ecbuild.exe文件)

node 相对模块路径 + install.js
node node_modules/vite-plugin-mock/node_modules/esbuild/install.js

vite vue项目 运行时 \esbuild\esbuild.exe 缺失 错误码 errno: -4058, code: ‘ENOENT‘,_第2张图片

vite vue项目 运行时 \esbuild\esbuild.exe 缺失 错误码 errno: -4058, code: ‘ENOENT‘,_第3张图片

D:\PengYe_code\2\vite-vue3-admin>node node_modules/vite-plugin-mock/node_modules/esbuild/install.js
D:\PengYe_code\2\vite-vue3-admin>npm run dev

> [email protected] dev
> vite

Pre-bundling dependencies:
  vue
  pinia
  vue-i18n
  vue-router
  lodash-es
  (...and 19 more)
(this will be run only when your dependencies or config have changed)

  vite v2.8.6 dev server running at:

  > Network:  http://192.168.0.107:8088/
  > Local:    http://localhost:8088/

  ready in 18555ms.

你可能感兴趣的:(vue.js,前端,javascript)