Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put link in console.log(). Node.js

I would like to do something like this:

console.log('Your server available at <a href="localhost:3000"> localhost:3000 </a>');

But unfortunately node console doesn't recognize 'a' tag.

Are any ideas how to put link in node console?

like image 796
TK-95 Avatar asked Mar 29 '16 21:03

TK-95


People also ask

How do you add a line in console log?

To create a multi line strings when printing to the JavaScript console, you need to add the new line character represented by the \n symbol. Alternatively, you can also add a new line break using Enter when you use the template literals syntax.

How do you create a link in node JS?

link() Method. The fs. link() method is used to create a hard link to the given path.


1 Answers

There is no way you can make an HTML tag interpreted by your the terminal, because your terminal has no ideas what html is.

You can just display a URL in console output like console.log('Your server available at http://localhost:3000

Most modern terminals will automatically parse it as a URL (if you put a valid URL there)

For example, Mac default terminal redirects to valid URL from console output if you double-click on it while holding Cmd

like image 169
Andrew Kovalenko Avatar answered Sep 28 '22 11:09

Andrew Kovalenko