| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/readjs/node_modules/win-detect-browsers/ |
Upload File : |
# win-detect-browsers
> Detects installed versions of Chrome, Firefox, Phantomjs (local and global), Internet Explorer, Safari and Opera. Supports Windows XP and up.
[](https://ci.appveyor.com/project/vweevers/win-detect-browsers) [](https://david-dm.org/vweevers/win-detect-browsers)
[Command line](#command-line) / [API](#api) / [License](#license)
## About
Basically, browser detection on Windows can't be done right. This is the *try-everything-and-fail-silently* approach. It accounts for x64/86 differences, normalizes environment variables, tries default locations, searches the registry (in the HKLM and HKCU hives), checks [Start Menu Internet Applications](http://msdn.microsoft.com/en-us/library/windows/desktop/dd203067(v=vs.85).aspx) and looks in `PATH`. After gathering paths, version numbers are either read from the executable metadata using `wmic` or with `browser -v`.
`browser-launcher` by substack has [poor Windows support](https://github.com/substack/browser-launcher/issues/7), and it prompted me to create this module. It is now used in [browser-launcher2](https://github.com/benderjs/browser-launcher2), an active fork of `browser-launcher`.
## Command line
Install globally and run:
npm i win-detect-browsers -g
win-detect-browsers
Example output on Windows XP:
chrome 39.0.2171.71
@ C:\Program Files\Google\Chrome\Application\chrome.exe
firefox 33.0.2
@ C:\Program Files\Mozilla Firefox\firefox.exe
ie 8.00.6001.18702
@ C:\Program Files\Internet Explorer\iexplore.exe
opera 26.0.1656.24
@ C:\Program Files\Opera\Launcher.exe
opera 26.0.1656.20
@ C:\Program Files\Opera beta\Launcher.exe
opera 27.0.1689.2
@ C:\Program Files\Opera developer\Launcher.exe
phantomjs 1.9.8
@ C:\Documents and Settings\..\Application Data\npm\phantomjs.CMD
Enable debug with `SET DEBUG=win-detect-browsers`.
### examples
Detect Internet Explorer and Phantomjs, without version numbers:
win-detect-browsers --no-version ie phantomjs
Return first found version of FF:
win-detect-browsers --lucky firefox
## API
`detect([names, opts,] cb)`
Where `names` is an array of browser names you want to find. If omitted, it will detect all browsers. Available options are:
- `boolean lucky` whether to end the search for a browser after the first result. Note that this result is not consistent, because search is asynchronous. Defaults to `false`, meaning: find all versions.
- `boolean version` whether to get version numbers, defaults to `true`.
## examples
Detect *[everything](http://youtu.be/k1yvvNvlXtg)*:
```js
var detect = require('win-detect-browsers')
detect(function(browsers){
var format = "\n%s %s\n @ %s"
browsers.forEach(function(b){
console.log(format, b.name, b.version, b.path)
})
})
```
Detect only Chrome and IE, without version numbers:
```js
detect(['chrome', 'ie'], {version: false}, cb)
```
## License
[MIT](http://opensource.org/licenses/MIT) © [Vincent Weevers](http://vincentweevers.nl)