npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chrome-location2

v4.0.0

Published

Approximates the current location of the Chrome browser across platforms.

Readme

Approximates the current location of the Chrome browser across platforms.

chrome-location2 Version Downloads workflow

  • By default checks only stable. Optionally can cascade to beta / dev / canary.
  • Supports macOS / Windows / Linux
  • Works both as an ES module or CommonJS

New in this version:

  • Honors environment overrides: CHROME_FOR_TESTING_PATH, CHROMIUM_BINARY, CHROME_BINARY
  • On macOS, auto-detects Chrome for Testing at /Applications/Google Chrome for Testing.app/...
  • Optional helper to throw with a friendly install guide when nothing is found
  • CLI output is colorized (green on success, red on error)
  • New: Cross-platform version API that does not execute the browser by default

Installation

# Pick one
pnpm add chrome-location2
npm i chrome-location2
yarn add chrome-location2

Support table

This table lists the default locations where Chrome is typically installed for each supported platform and channel. By default, only the Stable channel is checked. When fallback is enabled, the package checks these paths (in order) and returns the first one found.

Returns the first existing path found (given selected channels), or null if none are found.

Usage

Via Node.js (strict by default):

import chromeLocation from 'chrome-location2'

// Strict (Stable only)
console.log(chromeLocation())
// => "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" or null

// Enable fallback (Stable / Beta / Dev / Canary; includes Chromium on macOS/Windows; Chromium/Chromium-browser on Linux)
console.log(chromeLocation(true))
// => first found among Stable/Beta/Dev/Canary (or Chromium) or null

// Throw with a friendly, copy-pasteable guide when not found (path-only resolution; never executes the browser)
import {locateChromeOrExplain, getInstallGuidance, getChromeVersion} from 'chrome-location2'
try {
  const path = locateChromeOrExplain({allowFallback: true})
  console.log(path)

  // Cross-platform version (no exec by default)
  const v = getChromeVersion(path)
  console.log(v) // e.g. "120.0.6099.109" or null

  // Opt-in: allow executing the binary to fetch version on platforms without metadata (e.g. Linux)
  const v2 = getChromeVersion(path, {allowExec: true})
  console.log(v2)
} catch (e) {
  console.error(String(e))
  // Or print getInstallGuidance() explicitly
}

CommonJS:

const api = require('chrome-location2')
const locateChrome = api.default || api

// Strict (Stable only)
console.log(locateChrome())

// With fallback enabled
console.log(locateChrome(true))

// Helper that throws with guidance
try {
  const p = (
    api.locateChromeOrExplain || ((o) => locateChrome(o?.allowFallback))
  )({allowFallback: true})
  console.log(p)
} catch (e) {
  console.error(String(e))
}

Via CLI:

npx chrome-location2
# Strict (Stable only)

npx chrome-location2 --fallback
# Enable cascade (Stable / Beta / Dev / Canary)

# Short flag
npx chrome-location2 -f

# Respect environment overrides
CHROME_FOR_TESTING_PATH=/custom/path/to/chrome npx chrome-location2

# Print Chrome version instead of path (no exec by default)
npx chrome-location2 --chrome-version

# Allow executing the binary if metadata is unavailable (mainly Linux)
npx chrome-location2 --chrome-version --allow-exec

Exit behavior:

  • Prints the resolved path on success
  • Exits with code 1 and prints a guidance message if nothing suitable is found
  • When --chrome-version is used: prints version or exits with code 2 if not determinable without exec and --allow-exec was not provided

Notes:

  • Output is colorized when printed to a TTY (green success, red error)
  • After you run npx @puppeteer/browsers install chrome@stable once, we auto-detect Chrome for Testing from Puppeteer's cache on all platforms. No env vars needed.

When nothing is found

The helper returns actionable guidance (Vercel-like tone):

We couldn't find a Chrome/Chromium browser on this machine.

Here's the fastest way to get set up:

1) Install Chrome for Testing (recommended)
   npx @puppeteer/browsers install chrome@stable

Then re-run your command — we'll detect it automatically.

Alternatively, install Chromium via your system's package manager and re-run.

API

  • default export locateChrome(allowFallback?: boolean): string | null

    • Returns the first existing path among the selected channels or null.
    • When allowFallback is true, checks Stable → Beta → Dev → Canary. May also consider Chromium depending on platform.
  • locateChromeOrExplain(options?: boolean | { allowFallback?: boolean }): string

    • Returns a path if found, otherwise throws an Error with a friendly installation guide.
    • Path resolution never executes the browser.
  • getChromeVersion(bin: string, opts?: { allowExec?: boolean }): string | null

    • Cross-platform version resolver that does not execute the browser by default.
    • Windows: reads PE file metadata via PowerShell (no GUI spawn).
    • macOS: reads Info.plist (no GUI spawn).
    • Linux/other: attempts to infer from Puppeteer cache path; if not available, returns null unless allowExec is true.
  • getInstallGuidance(): string

    • Returns the same guidance text used by locateChromeOrExplain().

Environment overrides

If any of these environment variables are set and point to an existing binary, they take precedence:

  • CHROME_FOR_TESTING_PATH
  • CHROMIUM_BINARY
  • CHROME_BINARY

Related projects

License

MIT (c) Cezar Augusto.