Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

chrome-launcher

> 编程语言
Open source

Launch Google Chrome with ease from node.

1.4K stars0 likes2 views
WebsiteGitHub

About

Launch Google Chrome with ease from node.

Chrome Launcher

Launch Google Chrome with ease from node.

  • Disables many Chrome services that add noise to automated scenarios
    • See our chrome-flags-for-tools.md doc for an in-depth accounting of Chrome flags that are useful for measurement/automation tools.
  • Opens up the browser's remote-debugging-port on an available port
  • Automagically locates a Chrome binary to launch
  • Uses a fresh Chrome profile for each launch, and cleans itself up on kill()
  • Binds Ctrl-C (by default) to terminate the Chrome process
  • Exposes a small set of options for configurability over these details

Once launched, interacting with the browser must be done over the devtools protocol, typically via chrome-remote-interface. For many cases Puppeteer is recommended, though it has its own chrome launching mechanism.

Installing

bash
yarn add chrome-launcher

# or with npm:
npm install chrome-launcher

API

.launch([opts])

Launch options

…

Launched chrome interface

.launch().then(chrome => ...

javascript
// The remote debugging port exposed by the launched chrome
chrome.port: number;

// Method to kill Chrome (and cleanup the profile folder)
chrome.kill: () => Promise<void>;

// The process id
chrome.pid: number;

// The childProcess object for the launched Chrome
chrome.process: childProcess

// If chromeFlags contains --remote-debugging-pipe. Otherwise remoteDebuggingPipes is null.
chrome.remoteDebuggingPipes.incoming: ReadableStream
chrome.remoteDebuggingPipes.outgoing: WritableStream

When --remote-debugging-pipe is passed via chromeFlags, then port will be unusable (0) by default. Instead, debugging messages are exchanged via remoteDebuggingPipes.incoming and remoteDebuggingPipes.outgoing. The data in these pipes are JSON values terminated by a NULL byte (\x00). Data written to remoteDebuggingPipes.outgoing are sent to Chrome, data read from remoteDebuggingPipes.incoming are received from Chrome.

ChromeLauncher.Launcher.defaultFlags()

Returns an Array<string> of the default flags Chrome is launched with. Typically used along with the ignoreDefaultFlags and chromeFlags options.

Note: This array will exclude the following flags: --remote-debugging-port --disable-setuid-sandbox --user-data-dir.

ChromeLauncher.Launcher.getInstallations()

Returns 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.

Note: This method performs synchronous I/O operations.

.killAll()

Attempts to kill all Chrome instances created with .launch([opts]). 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.

javascript
import * as ChromeLauncher from 'chrome-launcher';

async function cleanup() {
  await ChromeLauncher.killAll();
}

Examples

Launching chrome:

javascript
import * as ChromeLauncher from 'chrome-launcher';

ChromeLauncher.launch({
  startingUrl: 'https://google.com'
}).then(chrome => {
  console.log(`Chrome debugging port running on ${chrome.port}`);
});

Launching headless chrome:

javascript
import * as ChromeLauncher from 'chrome-launcher';

ChromeLauncher.launch({
  startingUrl: 'https://google.com',
  chromeFlags: ['--headless', '--disable-gpu']
}).then(chrome => {
  console.log(`Chrome debugging port running on ${chrome.port}`);
});

Launching with support for extensions and audio:

javascript
import * as ChromeLauncher from 'chrome-launcher';

const newFlags = ChromeLauncher.Launcher.defaultFlags().filter(flag => flag !== '--disable-extensions' && flag !== '--mute-audio');

ChromeLauncher.launch({
  ignoreDefaultFlags: true,
  chromeFlags: newFlags,
}).then(chrome => { ... });

To programatically load an extension at runtime, use --remote-debugging-pipe as shown in test/load-extension-test.ts.

Continuous Integration

In 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. Alternatively, you can also install Chrome using the download-chrome.sh script.

Then in .travis.yml, use it like so:

yaml
language: node_js
install:
  - yarn install
before_script:
  - export DISPLAY=:99.0
  - export CHROME_PATH="$(pwd)/chrome-linux/chrome"
  - sh -e /etc/init.d/xvfb start
  - sleep 3 # wait for xvfb to boot

addons:
  chrome: stable

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言