Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check whether Firefox or Chrome is installed on Windows? #167

Closed
KerimG opened this issue Jan 30, 2020 · 2 comments
Closed

How to check whether Firefox or Chrome is installed on Windows? #167

KerimG opened this issue Jan 30, 2020 · 2 comments

Comments

@KerimG
Copy link

KerimG commented Jan 30, 2020

Hey all,

I want to open a URL with either Chrome or Firefox and I have to know which one is available, because of the differences in their command line arguments. I tried wrapping the open funtion in a try/catch but that doesn't seem to work.

try {
    await opn("http://localhost:12344", { app: "firefox" });
  } catch (error) {
    console.log("caught");
  }

Even if I were to catch it, windows shows the error message that the program in question doesn't exist. Basically this:

image

I figure I have to first check whether Chrome or Firefox are available. How would I do that?

@sindresorhus
Copy link
Owner

There's no easy cross-platform way to do this, unfortunately.

For Windows, I found this package: https://github.com/vweevers/win-detect-browsers

If anyone has more info about this, please submit a tip to the readme.

@KerimG
Copy link
Author

KerimG commented Feb 13, 2020

@sindresorhus

I don't really need a cross-platform solution, at the moment. I think it's somewhat easy to check for available browsers in a *nix environment but it's a hassle in Windows. Looks like that win-detect-browsers works well, though. Thank you very much!

@KerimG KerimG closed this as completed Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants