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 🙏

© 2024 – Pkg Stats / Ryan Hefner

win-detect-browsers

v7.0.0

Published

Fast and native browser detection on Windows

Downloads

11,002

Readme

win-detect-browsers

Fast and native browser detection on Windows. Detects installed versions of Beaker, Brave, Chrome, Chromium, Firefox, Internet Explorer, Maxthon, Opera, Safari and Yandex.

npm Node version Test Standard Common Changelog

Table of Contents

Usage

If you are upgrading: please see the changelog.

const detect = require('win-detect-browsers')

// All browsers
detect(function (err, browsers) {
  if (err) throw err
  console.log(browsers)
})

// All browsers with promise
const browsers = await detect()

// Search only for Chrome and Firefox
detect(['chrome', 'firefox'], function (err, browsers) {
  if (err) throw err

  for (let b of browsers) {
    console.log(b.version) // '57.0.2931.0'
    console.log(b.channel) // 'canary'
  }
})

API

detect([names][, callback])

names is an array of browser names you want to find. If omitted or empty, it will detect everything. The callback receives an error if any and an array of results. A result is excluded if its path has no .exe extension or if its version could not be read. If no callback is provided, a promise is returned.

Each result is an object with the following properties:

  • name (string): chrome, chromium, firefox, beaker, brave, ie, msedge, maxthon, opera, safari, yandex
  • path (string): absolute path to executable
  • version (string)
  • arch (string): CPU type the executable was built for: amd64, i386 or other;
  • info (object): executable metadata (see sample below).

Additional properties are usually available but not guaranteed:

  • channel (string):
    • Chrome: stable, canary, beta or dev
    • Firefox: release, developer, nightly or esr
    • Older versions of Firefox: aurora, beta or rc;
    • Opera: stable, beta or developer.

CLI

win-detect-browsers [options] [name, name..]

Write browsers to stdout as a JSON array. Includes all browsers unless one or more names are given (see list above).

Options:

  • --help -h: Show help
  • --version -v: Show CLI version number
  • --summary -s: Less properties;
  • --debug -d: Enable debug output.

Sample

On Windows 10:

[
  {
    "name": "ie",
    "path": "C:\\Program Files\\Internet Explorer\\iexplore.exe",
    "version": "11.0.17134.1",
    "arch": "amd64",
    "info": {
      "FileVersion": "11.0.17134.1",
      "CompanyName": "Microsoft Corporation",
      "FileDescription": "Internet Explorer",
      "InternalName": "iexplore",
      "LegalCopyright": "© Microsoft Corporation. Alle rechten voorbehouden.",
      "OriginalFilename": "IEXPLORE.EXE.MUI",
      "ProductName": "Internet Explorer",
      "ProductVersion": "11.00.17134.1"
    }
  },
  {
    "name": "ie",
    "path": "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe",
    "version": "11.0.17134.1",
    "arch": "i386",
    "info": {
      "FileVersion": "11.0.17134.1",
      "CompanyName": "Microsoft Corporation",
      "FileDescription": "Internet Explorer",
      "InternalName": "iexplore",
      "LegalCopyright": "© Microsoft Corporation. Alle rechten voorbehouden.",
      "OriginalFilename": "IEXPLORE.EXE.MUI",
      "ProductName": "Internet Explorer",
      "ProductVersion": "11.00.17134.1"
    }
  },
  {
    "name": "firefox",
    "path": "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
    "version": "61.0.0.6711",
    "channel": "release",
    "arch": "amd64",
    "info": {
      "FileVersion": "61.0.0.6711",
      "LegalCopyright": "©Firefox and Mozilla Developers; available under the MPL 2 license.",
      "CompanyName": "Mozilla Corporation",
      "FileDescription": "Firefox",
      "ProductVersion": "61.0",
      "InternalName": "Firefox",
      "LegalTrademarks": "Firefox is a Trademark of The Mozilla Foundation.",
      "OriginalFilename": "../../dist/bin/firefox.exe",
      "ProductName": "Firefox",
      "BuildID": "20180517141400"
    }
  },
  {
    "name": "firefox",
    "path": "C:\\Program Files\\Firefox Developer Edition\\firefox.exe",
    "version": "61.0.0.6711",
    "channel": "developer",
    "arch": "amd64",
    "info": {
      "FileVersion": "61.0.0.6711",
      "LegalCopyright": "©Firefox and Mozilla Developers; available under the MPL 2 license.",
      "CompanyName": "Mozilla Corporation",
      "FileDescription": "Firefox Developer Edition",
      "ProductVersion": "61.0",
      "InternalName": "Firefox Developer Edition",
      "LegalTrademarks": "Firefox is a Trademark of The Mozilla Foundation.",
      "OriginalFilename": "../../dist/bin/firefox.exe",
      "ProductName": "Firefox Developer Edition",
      "BuildID": "20180517141400"
    }
  },
  {
    "name": "firefox",
    "path": "C:\\Program Files\\Firefox Nightly\\firefox.exe",
    "version": "62.0.0.6712",
    "channel": "nightly",
    "arch": "amd64",
    "info": {
      "FileVersion": "62.0.0.6712",
      "LegalCopyright": "©Firefox and Mozilla Developers; available under the MPL 2 license.",
      "CompanyName": "Mozilla Corporation",
      "FileDescription": "Firefox Nightly",
      "ProductVersion": "62.0a1",
      "InternalName": "Firefox Nightly",
      "LegalTrademarks": "Firefox is a Trademark of The Mozilla Foundation.",
      "OriginalFilename": "firefox.exe",
      "ProductName": "Firefox Nightly",
      "BuildID": "20180518222751"
    }
  },
  {
    "name": "chrome",
    "path": "C:\\Users\\vweevers\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe",
    "version": "68.0.3436.0",
    "channel": "canary",
    "arch": "amd64",
    "info": {
      "FileVersion": "68.0.3436.0",
      "CompanyName": "Google Inc.",
      "FileDescription": "Google Chrome",
      "InternalName": "chrome_exe",
      "LegalCopyright": "Copyright 2017 Google Inc. All rights reserved.",
      "OriginalFilename": "chrome.exe",
      "ProductName": "Google Chrome",
      "ProductVersion": "68.0.3436.0",
      "CompanyShortName": "Google",
      "ProductShortName": "Chrome",
      "LastChange": "e0f81fe637f233bf12e821915b72bc8d2194c3f2-refs/branch-heads/3436@{#1}",
      "Official Build": "1"
    }
  },
  {
    "name": "chrome",
    "path": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
    "version": "66.0.3359.181",
    "channel": "stable",
    "arch": "amd64",
    "info": {
      "FileVersion": "66.0.3359.181",
      "CompanyName": "Google Inc.",
      "FileDescription": "Google Chrome",
      "InternalName": "chrome_exe",
      "LegalCopyright": "Copyright 2017 Google Inc. All rights reserved.",
      "OriginalFilename": "chrome.exe",
      "ProductName": "Google Chrome",
      "ProductVersion": "66.0.3359.181",
      "CompanyShortName": "Google",
      "ProductShortName": "Chrome",
      "LastChange": "a10b9cedb40738cb152f8148ddab4891df876959-refs/branch-heads/3359@{#828}",
      "Official Build": "1"
    }
  },
  {
    "name": "opera",
    "path": "C:\\Program Files\\Opera beta\\Launcher.exe",
    "version": "53.0.2907.31",
    "channel": "beta",
    "arch": "amd64",
    "info": {
      "FileVersion": "53.0.2907.31",
      "LegalCopyright": "Copyright Opera Software 2018",
      "InternalName": "Opera",
      "CompanyName": "Opera Software",
      "ProductName": "Opera beta Internet Browser",
      "ProductVersion": "53.0.2907.31",
      "FileDescription": "Opera beta Internet Browser"
    }
  }
]

Install

With npm do:

npm install win-detect-browsers     # For API
npm install win-detect-browsers -g  # For CLI

Background

Browser detection on Windows can't be done right. This is the try-everything-and-fail-silently approach. It accounts for architecture differences, normalizes environment variables, tries default locations, searches the registry (in the HKLM and HKCU hives as well as WoW counterparts) (including Start Menu Internet Applications, Google Updater and more), and looks in PATH. Version numbers are then read from the executable metadata.

browser-launcher by substack has poor Windows support, and it prompted me to create this module. It is now used in browser-launcher2, ~~an active~~ a once active fork of browser-launcher.

License

MIT