brave-location
v3.1.0
Published
Approximates the current location of the Brave browser across platforms.
Maintainers
Readme
Approximates the current location of the Brave browser across platforms.
brave-location

- By default checks only
stable. Optionally can cascade tobeta/nightly. - Supports macOS / Windows / Linux
- Works both as an ES module or CommonJS
Installation
npm i brave-locationSupport table
This table lists the default locations where Brave 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 the selected channels), or null if none are found.
Usage
Via Node.js (strict by default):
import braveLocation from "brave-location";
import {
locateBraveOrExplain,
getInstallGuidance,
getBraveVersion
} from "brave-location";
// Strict (Stable only)
console.log(braveLocation());
// => "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" or null
// Enable fallback (Stable / Beta / Nightly)
console.log(braveLocation(true));
// => first found among Stable/Beta/Nightly or null
// Throw with a friendly guide when not found
try {
const bin = locateBraveOrExplain({allowFallback: true});
console.log(bin);
// Cross-platform version (no exec by default)
console.log(getBraveVersion(bin)); // e.g. "132.1.72.123" or null
// Opt-in: allow executing the binary (Linux/other)
console.log(getBraveVersion(bin, {allowExec: true}));
} catch (e) {
console.error(String(e));
// Or print getInstallGuidance() explicitly
}CommonJS:
const api = require('brave-location')
const locateBrave = api.default || apiVia CLI:
npx brave-location
# Strict (Stable only)
npx brave-location --fallback
# Enable cascade (Stable / Beta / Nightly)
# Respect environment overrides
BRAVE_BINARY=/custom/path/to/brave npx brave-location
# Print browser version (empty + exit code 2 if unavailable)
npx brave-location --brave-version
npx brave-location --browser-version
# Opt-in: allow executing the binary to fetch version
npx brave-location --browser-version --allow-execEnvironment overrides
If this environment variable is set and points to an existing binary, it takes precedence:
BRAVE_BINARY
API
default export locateBrave(allowFallback?: boolean): string | nulllocateBraveOrExplain(options?: boolean | { allowFallback?: boolean }): stringgetBraveVersion(bin: string, opts?: { allowExec?: boolean }): string | nullgetInstallGuidance(): string
Related projects
- chrome-location2
- chromium-location
- edge-location
- firefox-location2
- safari-location2
- opera-location2
- vivaldi-location2
- waterfox-location
- librewolf-location
- yandex-location
License
MIT (c) Cezar Augusto.
