{"_id":"chrome-launcher@1.2.2","bin":{"print-chrome-path":"bin/print-chrome-path.cjs"},"bugs":{"url":"https://github.com/GoogleChrome/chrome-launcher/issues"},"dist":{"shasum":"714c56cedd8ee8466fa70328944b44def5e56a74","tarball":"http://registry-npm.ywwl.com/chrome-launcher/download/chrome-launcher-1.2.2.tgz","fileCount":27,"integrity":"sha512-sI90u5qf3854bTrWsQMMdsQfSjjMbeSn7QtxVb9zrikf+QgMfHQ71KepHW7ZfixQKrDlAFKb+qnVlSR+xepBzw==","signatures":[{"sig":"MEQCIHH5pH153wTnx0i/R9M+JifV6U6E95pHm3AYkdKTd/s+AiABQkp+d5t+DlmZG3cE2D/XW+4jPi4fmbPgPJQtDo8EWQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCU4PsLSgkShf2miBCYchokbv3czcngE9yyVc47hNkmaAIgeKCOeHESt4n2iFyZ0O5whWqgHefssxhPbrRqe+A0Rcc="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/chrome-launcher@1.2.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":140303,"size":43534,"noattachment":false,"key":"/chrome-launcher/-/chrome-launcher-1.2.2.tgz"},"main":"./dist/index.js","name":"chrome-launcher","type":"module","types":"./dist/index.d.ts","author":{"name":"The Chromium Authors"},"engines":{"node":">=12.13.0"},"gitHead":"c08bf35b7927847a831706ecff201e3b90debfce","license":"Apache-2.0","scripts":{"dev":"tsc -w","test":"test/run-tests.sh","build":"tsc","format":"scripts/format.sh","reset-link":"(yarn unlink || true) && yarn link && yarn --cwd node_modules/lighthouse/ link chrome-launcher","type-check":"tsc --allowJs --checkJs --noEmit --target es2019 *.js","test-formatting":"test/check-formatting.sh"},"version":"1.2.2","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"1b11f441-957f-4b95-a831-5bbcb7900a09"}},"homepage":"https://github.com/GoogleChrome/chrome-launcher#readme","repository":{"url":"git+https://github.com/GoogleChrome/chrome-launcher.git","type":"git"},"_npmVersion":"11.19.0","description":"Launch latest Chrome with the Devtools Protocol port open","directories":{},"maintainers":[{"name":"paulirish","email":"npm@paul.irish"},{"name":"brendankenny","email":"bckenny@gmail.com"},{"name":"hoten","email":"cjamcl@gmail.com"},{"name":"adamraine","email":"ad.st.raine@gmail.com"}],"_nodeVersion":"24.21.0","dependencies":{"is-wsl":"^2.2.0","@types/node":"*","lighthouse-logger":"^2.0.1","escape-string-regexp":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"sinon":"^9.0.1","typescript":"^4.1.2","@types/sinon":"^9.0.1","clang-format":"^1.0.50"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chrome-launcher_1.2.2_1790721160085_0.6592911780753208"},"readme":"# Chrome Launcher [![GitHub Actions Status Badge](https://github.com/GoogleChrome/chrome-launcher/workflows/🛠/badge.svg)](https://github.com/GoogleChrome/chrome-launcher/actions) [![NPM chrome-launcher package](https://img.shields.io/npm/v/chrome-launcher.svg)](https://npmjs.org/package/chrome-launcher)\n\n<img src=\"https://user-images.githubusercontent.com/39191/29847271-a7ba82f8-8ccf-11e7-8d54-eb88fdf0b6d0.png\" align=right height=200>\n\nLaunch Google Chrome with ease from node.\n\n* [Disables many Chrome services](https://github.com/GoogleChrome/chrome-launcher/blob/main/src/flags.ts) that add noise to automated scenarios\n  * See our [chrome-flags-for-tools.md](https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md) doc for an in-depth accounting of Chrome flags that are useful for measurement/automation tools.\n* Opens up the browser's `remote-debugging-port` on an available port\n* Automagically locates a Chrome binary to launch\n* Uses a fresh Chrome profile for each launch, and cleans itself up on `kill()`\n* Binds `Ctrl-C` (by default) to terminate the Chrome process\n* Exposes a small set of [options](#api) for configurability over these details\n\nOnce launched, interacting with the browser must be done over the [devtools protocol](https://chromedevtools.github.io/devtools-protocol/), typically via [chrome-remote-interface](https://github.com/cyrus-and/chrome-remote-interface/). For many cases [Puppeteer](https://github.com/GoogleChrome/puppeteer) is recommended, though it has its own chrome launching mechanism.\n\n### Installing\n\n```sh\nyarn add chrome-launcher\n\n# or with npm:\nnpm install chrome-launcher\n```\n\n\n## API\n\n### `.launch([opts])`\n\n#### Launch options\n\n```js\n{\n  // (optional) remote debugging port number to use. If provided port is already busy, launch() will reject\n  // Default: an available port is autoselected\n  port: number;\n\n  // (optional) When `port` is specified *and* no Chrome is found at that port,\n  // * if `false` (default), chrome-launcher will launch a new Chrome with that port.\n  // * if `true`, throw an error\n  // This option is useful when you wish to explicitly connect to a running Chrome, such as on a mobile device via adb\n  // Default: false\n  portStrictMode: boolean;\n\n  // (optional) Additional flags to pass to Chrome, for example: ['--headless', '--disable-gpu']\n  // See: https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md\n  // Do note, many flags are set by default: https://github.com/GoogleChrome/chrome-launcher/blob/main/src/flags.ts\n  chromeFlags: Array<string>;\n\n  // (optional) Additional preferences to be set in Chrome, for example: {'download.default_directory': __dirname}\n  // See: https://chromium.googlesource.com/chromium/src/+/main/chrome/common/pref_names.cc\n  // Do note, if you set preferences when using your default profile it will overwrite these\n  prefs: {[key: string]: Object};\n\n  // (optional) Close the Chrome process on `Ctrl-C`\n  // Default: true\n  handleSIGINT: boolean;\n\n  // (optional) Explicit path of intended Chrome binary\n  // * If this `chromePath` option is defined, it will be used.\n  // * Otherwise, the `CHROME_PATH` env variable will be used if set. (`LIGHTHOUSE_CHROMIUM_PATH` is deprecated)\n  // * Otherwise, a detected Chrome Canary will be used if found\n  // * Otherwise, a detected Chrome (stable) will be used\n  chromePath: string;\n\n  // (optional) Chrome profile path to use, if set to `false` then the default profile will be used.\n  // By default, a fresh Chrome profile will be created\n  userDataDir: string | boolean;\n\n  // (optional) Starting URL to open the browser with\n  // Default: `about:blank`\n  startingUrl: string;\n\n  // (optional) Logging level\n  // Default: 'silent'\n  logLevel: 'verbose'|'info'|'error'|'silent';\n\n  // (optional) Flags specific in [flags.ts](src/flags.ts) will not be included.\n  // Typically used with the defaultFlags() method and chromeFlags option.\n  // Default: false\n  ignoreDefaultFlags: boolean;\n\n  // (optional) Interval in ms, which defines how often launcher checks browser port to be ready.\n  // Default: 500\n  connectionPollInterval: number;\n\n  // (optional) A number of retries, before browser launch considered unsuccessful.\n  // Default: 50\n  maxConnectionRetries: number;\n\n  // (optional) A dict of environmental key value pairs to pass to the spawned chrome process.\n  envVars: {[key: string]: string};\n};\n```\n\n#### Launched chrome interface\n\n#### `.launch().then(chrome => ...`\n\n```js\n// The remote debugging port exposed by the launched chrome\nchrome.port: number;\n\n// Method to kill Chrome (and cleanup the profile folder)\nchrome.kill: () => Promise<void>;\n\n// The process id\nchrome.pid: number;\n\n// The childProcess object for the launched Chrome\nchrome.process: childProcess\n\n// If chromeFlags contains --remote-debugging-pipe. Otherwise remoteDebuggingPipes is null.\nchrome.remoteDebuggingPipes.incoming: ReadableStream\nchrome.remoteDebuggingPipes.outgoing: WritableStream\n```\n\nWhen `--remote-debugging-pipe` is passed via `chromeFlags`, then `port` will be\nunusable (0) by default. Instead, debugging messages are exchanged via\n`remoteDebuggingPipes.incoming` and `remoteDebuggingPipes.outgoing`. The data\nin these pipes are JSON values terminated by a NULL byte (`\\x00`).\nData written to `remoteDebuggingPipes.outgoing` are sent to Chrome,\ndata read from `remoteDebuggingPipes.incoming` are received from Chrome.\n\n### `ChromeLauncher.Launcher.defaultFlags()`\n\nReturns an `Array<string>` of the default [flags](docs/chrome-flags-for-tools.md) Chrome is launched with. Typically used along with the `ignoreDefaultFlags` and `chromeFlags` options.\n\nNote: This array will exclude the following flags: `--remote-debugging-port` `--disable-setuid-sandbox` `--user-data-dir`.\n\n### `ChromeLauncher.Launcher.getInstallations()`\n\nReturns an `Array<string>` of paths to available Chrome installations. When `chromePath` is not provided to `.launch()`, the first installation returned from this method is used instead.\n\nNote: This method performs synchronous I/O operations.\n\n### `.killAll()`\n\nAttempts to kill all Chrome instances created with [`.launch([opts])`](#launchopts). Returns a Promise that resolves to an array of errors that occurred while killing instances. If all instances were killed successfully, the array will be empty.\n\n```js\nimport * as ChromeLauncher from 'chrome-launcher';\n\nasync function cleanup() {\n  await ChromeLauncher.killAll();\n}\n```\n\n## Examples\n\n#### Launching chrome:\n\n```js\nimport * as ChromeLauncher from 'chrome-launcher';\n\nChromeLauncher.launch({\n  startingUrl: 'https://google.com'\n}).then(chrome => {\n  console.log(`Chrome debugging port running on ${chrome.port}`);\n});\n```\n\n\n#### Launching headless chrome:\n\n```js\nimport * as ChromeLauncher from 'chrome-launcher';\n\nChromeLauncher.launch({\n  startingUrl: 'https://google.com',\n  chromeFlags: ['--headless', '--disable-gpu']\n}).then(chrome => {\n  console.log(`Chrome debugging port running on ${chrome.port}`);\n});\n```\n\n#### Launching with support for extensions and audio:\n\n```js\nimport * as ChromeLauncher from 'chrome-launcher';\n\nconst newFlags = ChromeLauncher.Launcher.defaultFlags().filter(flag => flag !== '--disable-extensions' && flag !== '--mute-audio');\n\nChromeLauncher.launch({\n  ignoreDefaultFlags: true,\n  chromeFlags: newFlags,\n}).then(chrome => { ... });\n```\n\nTo programatically load an extension at runtime, use `--remote-debugging-pipe`\nas shown in [test/load-extension-test.ts](test/load-extension-test.ts).\n\n### Continuous Integration\n\nIn a CI environment like Travis, Chrome may not be installed. If you want to use `chrome-launcher`, Travis can [install Chrome at run time with an addon](https://docs.travis-ci.com/user/chrome).  Alternatively, you can also install Chrome using the [`download-chrome.sh`](https://raw.githubusercontent.com/GoogleChrome/chrome-launcher/v0.8.0/scripts/download-chrome.sh) script.\n\nThen in `.travis.yml`, use it like so:\n\n```yaml\nlanguage: node_js\ninstall:\n  - yarn install\nbefore_script:\n  - export DISPLAY=:99.0\n  - export CHROME_PATH=\"$(pwd)/chrome-linux/chrome\"\n  - sh -e /etc/init.d/xvfb start\n  - sleep 3 # wait for xvfb to boot\n\naddons:\n  chrome: stable\n```\n","publish_time":1790721160183,"_cnpm_publish_time":1790721160183,"dist-tags":{"latest":"1.2.2"}}