Arch Linux Manjaro:npm start 未检测到 chrome 并返回 ENOENT 错误

Arch Linux Manjaro:npm start 未检测到 chrome 并返回 ENOENT 错误

我正在使用 Manjaro 并从 AUR 包下载了 google-chrome-stable。即使 google chrome 设置为默认浏览器,npm start 仍然默认打开 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' ]
}

答案1

如果您使用react-scripts它作为工具链,您可以将BROWSER环境变量设置为您选择的浏览器。

要使其适用于您的所有项目,请编辑您的.bashrc文件并添加:

export BROWSER=chrome

相关内容