npm开始未检测到chrome并返回ENOENT错误(ARCH Linux)



我正在使用Manjaro,并且已经从AUR包下载了googlechrome-stable。即使谷歌chrome被设置为默认浏览器,npm启动仍然默认打开firefox,在我删除firefox后,我开始收到以下错误

Starting the development server...
node:events:342
throw er; // Unhandled 'error' event
^
Error: spawn /usr/bin/firefox ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:480: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:288:12)
at onErrorNT (node:internal/child_process:480:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /usr/bin/firefox',
path: '/usr/bin/firefox',
spawnargs: [ 'http://localhost:3000' ]
}
React使用BROWSER环境变量来决定要使用的浏览器。试着如下运行您的React应用程序:
BROWSER=/usr/bin/google-chrome-stable npm start

如果效果良好,您可以通过添加将Chrome设置为默认设置

export BROWSER=/usr/bin/google-chrome-stable

到您的终端配置文件(如果您使用的是zsh,则为~/.zshrc(。

最新更新