open
npm module: Open stuff like URLs, files, executables. Cross-platform.
npm install open
# global
npm install -g open
It can open a browser (or app) with the provided URLs:
let open = require("open")
# Use default browser
open("https://google.com")
open("https://google.com", {app: "firefox"})
For the Nodejs app, after creating a localhost server, we can let it open the IP address automatically with the default browser.
Related
We can use live-server
or http-server
to create an http server and auto o[en its address in a web browser:
For live-server
, simple cd to the dir and run:
live-server
For http-server
, we need to add -o
:
http-server -o -a localhost