Open exists now, use this. :)
Install with:
$ npm install
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']}); })();
app:... option:
Type: string | string[]
Specify the application to open the target or an array with the arguments of the application and application.
The name of the application is platform dependent. Do not write code hard in reusable modules. For example, Chrome is Google Chrome for MacOS, Google Chrome for Linux, and Chrome for Windows.
You can also specify the full path in the application. For example, for WSL, it might be / mnt / c / Program Files (x86) /Google/Chrome/Application/chrome.exe to install Chrome on Windows.
Example:
open('http://localhost', {app: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"});
ctide 05 Oct '11 at 17:08 2011-10-05 17:08
source share