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

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

> vite-vue3-admin@1.0.2 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' ]
}

在这里插入图片描述

原因解析

因为 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
在这里插入图片描述

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

> vite-vue3-admin@1.0.2 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.

`

Logo

前往低代码交流专区

更多推荐