Link in the terminal

Asked

Viewed 57 times

1

Is there any way to make when the localhost:3000, who is in the terminal, be pressed ctrl + click the browser opens on the page in question ( localhost:3000 ) ... this in a Javascript code :

console.log('\nServidor iniciado em \033[36mlocalhost:3000\033[37m\n')

Obs : I searched but only find references of how to create an HTML link <a>: (</a>

1 answer

0


I believe shortcut is not possible, but you can run command to open. Below examples, when running:

npm start

It will automatically open the browser after starting the App. Add one of the codes below in package json. of his project.

In the Linux:

"scripts": {
    "start": "node app.js && xdg-open http://localhost:3000"
}

In the Mac:

"scripts": {
    "start": "node app.js && open http://localhost:3000"
}

In the Windows:

"scripts": {
    "start": "node app.js && start http://localhost:3000"
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.