Open exists now, use that. :)
Install with:
$ npm install --save open
Use with:
const open = require('open');
// Opens the image in the default image viewer
(async () => {
await open('unicorn.png', {wait: true});
console.log('The image viewer app closed');
// Opens the url in the default browser
await open('https://sindresorhus.com');
// Specify the app to open in
await open('https://sindresorhus.com', {app: 'firefox'});
// Specify app arguments
await open('https://sindresorhus.com', {app: ['google chrome', '--incognito']});
})();
The app: ...
option:
Type: string | string[]
Specify the app to open the target with, or an array with the app and
app arguments.
The app name is platform dependent. Don't hard code it in reusable
modules. For example, Chrome is google chrome on macOS, google-chrome
on Linux and chrome on Windows.
You may also pass in the app's full path. For example on WSL, this can
be /mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe for
the Windows installation of Chrome.
Example:
open('http://localhost', {app: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"});