chrome-launcher
chrome-launcher copied to clipboard
OSX ChromeNotInstalledError - My resolution
When attempting to chromeLauncher.launch, I receive the following error trace:
ChromeNotInstalledError
at new LauncherError (/Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/utils.js:37:22)
at new ChromeNotInstalledError (/Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/utils.js:68:9)
at Launcher.<anonymous> (/Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/chrome-launcher.js:163:27)
at Generator.next (<anonymous>)
at /Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/chrome-launcher.js:13:71
at new Promise (<anonymous>)
at __awaiter (/Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/chrome-launcher.js:9:12)
at Launcher.launch (/Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/chrome-launcher.js:149:16)
at Object.<anonymous> (/Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/chrome-launcher.js:48:24)
at Generator.next (<anonymous>) {
message: 'No Chrome installations found.',
code: 'ERR_LAUNCHER_NOT_INSTALLED'
}
I read through chrome-launcher source until i found this regex block, which appears to have the correct path to my chrome installation. I tried manually setting CHROME_PATH=/Applications/Google\ Chrome\ Canary.app process.env var to get around this, and ran up against a different error:
TypeError: Cannot read property 'toString' of undefined
at Launcher.<anonymous> (/Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/chrome-launcher.js:191:64)
at Generator.next (<anonymous>)
at fulfilled (/Users/justincohen/lighthouse/node_modules/chrome-launcher/dist/chrome-launcher.js:10:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
events.js:288
throw er; // Unhandled 'error' event
^
Error: spawn /Applications/Google Chrome Canary.app EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'EACCES',
code: 'EACCES',
syscall: 'spawn /Applications/Google Chrome Canary.app',
path: '/Applications/Google Chrome Canary.app',
This EACCES error was because that CHROME_PATH is not the path to the binary, but the higher level directory.
Resolution
I have successfully launched chromeLauncher by passing the full path to the binary as an ENV var: CHROME_PATH=/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary. I'm not sure where chromeLauncher is getting lost, but this is how I was able to resolve it.
Tech Details
chrome-launcher version: 0.13.3 osx version: 10.15.3
Full contents of my index.js:
const chromeLauncher = require('chrome-launcher');
chromeLauncher.launch({
startingUrl: "https://www.google.com"
}).catch(err => console.error(err));
Successful with the following command CHROME_PATH=/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary node index.js
Thank you, same issue here. Your tip worked for me.
Same workaround fixes this issue if you only have Brave installed and no other Chromium-based browser (Mozilla's web-ext package uses chrome-launcher)
CHROME_PATH=/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser web-ext run --target chromium
Same workaround fixes this issue if you only have Brave installed and no other Chromium-based browser (Mozilla's
web-extpackage uses chrome-launcher)CHROME_PATH=/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser web-ext run --target chromium
Thanks! But web-ext doesn't seem to pass environment variable so easily. Example for linux:
CHROME_PATH=/usr/bin/brave web-ext run --target chromium
Doesn't work. However, WEB_EXT_CHROMIUM_BINARY will be recognized by web-ext and used in place of --chromium-binary flag:
WEB_EXT_CHROMIUM_BINARY=/usr/bin/brave web-ext run --target chromium
Works like a charm :+1:
~~(Also, now that I saw a bit of ugliness which OS X paths are, I'm very glad I didn't waste time and money on Mac. :joy:)~~