Skip to content

Vite项目在Centos 7环境下报错Error: spawn xdg-open ENOENT

在IDEA连服务器远程编码时,发现vite项目在执行vite命令会报错。

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

Error: spawn xdg-open 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: -2,
  code: 'ENOENT',
  syscall: 'spawn xdg-open',
  path: 'xdg-open',
  spawnargs: [ 'http://localhost:3001/' ]
}

Process finished with exit code 1

解决方案

在服务器上执行下面的命令即可。

yum install xdg-utils

天上的神明与星辰,人间的艺术和真纯,我们所敬畏和热爱的,莫过于此。