我试图在我的节点码头容器中查看Vitest的花式UI服务器。但却无法启动和运行。当运行npm脚本vitest --ui
时,我会得到一个节点错误spawn xdg-open ENOENT
。
在这里,完整的错误消息:
$ npm run test-ui
> wpvite@0.0.0 test-ui
> vitest --ui
DEV v0.23.4 /home/node/apps/main/frontend
UI started at http://localhost:51204/__vitest__/
node:events:491
throw er; // Unhandled 'error' event
^
Error: spawn xdg-open ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn xdg-open',
path: 'xdg-open',
spawnargs: [ 'https://localhost:51204/__vitest__/' ]
}
Node.js v18.10.0
谷歌一点帮助都没有--甚至与Vitest没有任何关系。而且,我显然不是Node.js专家。
发布于 2022-10-04 02:52:08
尽管Node.js错误消息对我来说非常神秘,但我还是很幸运地使用了Ubuntu作为我的主要操作系统(除了macOS),这使我在错误消息中引起了对xdg-open
的注意--我偶尔会使用这个命令在Ubuntu上打开各种程序/应用程序。不知道为什么,但是您需要在您的系统上安装xdg,才能运行vitest --ui
,尽管它在Vitest和Vite Github repos中都没有提到过一个单词。无论如何,对于基于debian的容器,它是:
apt install xdg-utils --fix-missing
尽管这使得ENOENT错误消失,UI服务器启动时没有错误,但由于一些运行时-dom错误,我仍然没有看到UI应用程序.我放弃了。但也许其他人觉得xdg打开的信息很有用。
更新:它起作用了!
我只需将/__vitest__/
附加到我的代理本地url中,就像文档中清楚描述的那样:
“然后您可以访问
http://localhost:51204/__vitest__/
的Vitest UI”
https://stackoverflow.com/questions/73942710
复制相似问题