Use the express and child_process plug-ins

npm install express / / service
npm install child_process // Open the default browser
Copy the code

Start by creating a run.js file with the following contents

// Node starts a local service
const express = require('express')
const app = express()
app.use(express.static('/'))
const open = require('child_process')
app.listen(8080.() = > {
  open.exec('start http://localhost:8080')
  console.log('Open URL http://localhost:8080')})Copy the code

A service with port 8080 was started. Note: Avoid services that already have port 8080