edge-location
v2.3.0
Published
Approximates the current location of the Edge browser across platforms.
Maintainers
Readme
Approximates the current location of the Edge browser across platforms.
edge-location

- By default checks only
stable. Optionally can cascade tobeta/dev/canary. - Supports macOS / Windows / Linux
- Works both as an ES module or CommonJS
Installation
npm i edge-locationUsage
Via Node.js (strict by default):
import edgeLocation from 'edge-location'
// Strict (Stable only)
console.log(edgeLocation())
// => "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" or null
// Enable fallback (Stable / Beta / Dev / Canary)
console.log(edgeLocation(true))
// => first found among Stable/Beta/Dev/Canary or null
// Throw with an install guide when not found
import {locateEdgeOrExplain, getInstallGuidance} from 'edge-location'
try {
const path = locateEdgeOrExplain({allowFallback: true})
console.log(path)
} catch (e) {
console.error(String(e))
// Or print getInstallGuidance() explicitly
}CommonJS:
const api = require('edge-location')
const locateEdge = api.default || apiVia CLI:
npx edge-location
# Strict (Stable only)
npx edge-location --fallback
# Enable cascade (Stable / Beta / Dev / Canary)
# Respect environment overrides
EDGE_BINARY=/custom/path/to/msedge npx edge-location
# If not found, install Edge via Playwright and re-run
npx playwright install msedgeEnvironment overrides
If this environment variable is set and points to an existing binary, it takes precedence:
EDGE_BINARY
When nothing is found
When nothing is found, the helper throws with this message:
We couldn't find a Microsoft Edge browser on this machine.
To install one:
1) Install Edge via Playwright (recommended for CI/dev)
npx playwright install msedge
Re-run your command afterward and it will be detected automatically.
Alternatively, install Microsoft Edge from the official site and re-run.Support table
By default, only the Stable channel is checked. When fallback is enabled, Beta, Dev, and Canary are also checked (in that order) and the first existing path is returned.
Returns the first existing path found (given selected channels), or null if none are found.
API
default export locateEdge(allowFallback?: boolean): string | null- Returns the first existing path among the selected channels or
null. - When
allowFallbackistrue, checks Stable → Beta → Dev → Canary.
- Returns the first existing path among the selected channels or
locateEdgeOrExplain(options?: boolean | { allowFallback?: boolean }): string- Returns a path if found, otherwise throws an
Errorwith a friendly installation guide.
- Returns a path if found, otherwise throws an
getEdgeVersion(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: returns
nullunlessallowExecistrue, then tries--version.
getInstallGuidance(): string- Returns the same guidance text used by
locateEdgeOrExplain().
- Returns the same guidance text used by
Related projects
- brave-location
- chrome-location2
- chromium-location
- firefox-location2
- safari-location2
- opera-location2
- vivaldi-location2
- waterfox-location
- librewolf-location
- yandex-location
License
MIT (c) Cezar Augusto.
