How to output emoji to console in Node.js (on Windows)?

Viewed 17351

On Windows, there's some basic emoji support in the console, so that I can get a monochrome glyph if I type, e.g. or . I can output a string from PowerShell or a C# console application or Python and they all show those characters fine enough.

However, from Node.js, I can only get a couple of emoji to display (e.g. ), but not other (instead of I see ). However, if I throw a string with those characters, they display correctly.

console.log('  ☕ ');
throw '  ☕ ';

If I run the above script, the output is

 � ☕

C:\Code\emojitest\emojitest.js:2
throw '  ☕ '; 
^
  ☕

Is there anyway that I can output those emojis correctly without throwing an error? Or is that exception happening outside of what's available to me through the standard Node.js APIs?

3 Answers

The next "Windows Terminal" (from Kayla Cinnamon) and the Microsoft/Terminal project should be able to display emojis.

This will be available starting June 2019. Through the use of the Consolas font, partial Unicode support will be provided.

The request is in progress in Microsoft/Terminal issue 387.
And Microsoft/Terminal issue 190 formally demands "Add emoji support to Windows Console".

But there are still issues (March 2019):

I updated my Win10 from 1803 to 1809 several days ago, and now all characters >= U+10000 (UTF-8 with 4 bytes or more) no longer display.
I have also tried the newest insider version(Windows 10 Insider Preview 18358.1 (19h1_release)), unfortunately, this bug still exists.

Related