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

相關內容