brave-location
v3.0.4
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 command-line tool
Support 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
}Via 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-exec
### Behavior change
As of this version, the default behavior is strict (Stable only). To search Beta/Nightly as fallbacks, pass `true` to the Node API or use the `--fallback`/`-f` CLI flag.Environment 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
License
MIT (c) Cezar Augusto.
