Reputation: 1170
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?
Upvotes: 19
Views: 22255
Reputation: 36273
You don't need this. Some terminals started supporting links not long time ago. I think it was around 2017.
You will find more info here: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
Upvotes: 0
Reputation: 2111
console.log in Node renders text in the console window (command prompt in Windows) which does not know how to interpret html tags. I am afraid that you would not be able to do that unless you find a 3rd party plugin (if such plugin even exists) that allow that.
Hope that helps.
Upvotes: 2
Reputation: 6750
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
Upvotes: 22