Node: Foreground Magenta is not shown well in powershell(windows)

Created on 15 Jul 2017  路  10Comments  路  Source: nodejs/node

  • Version:6.9.5, 8.1.4
  • Platform:Windows 10 x64(16241 and some old versions)
  • Subsystem:


Foreground Magenta is shown as blue(the default background) in power shell, so it make the output
totally unreadable.
Not sure if it's a bug of windows, since powershell is now the default console in windows instead of cmd, could someone make an fix for this or reported to Microsoft?

Run on an new powershell(Not run powershell on cmd), found something magenta is not shown, but can be copy.

  1. Test 1(node/REPL)
> new Date()

image

The output is not shown.

  1. Test 2(npm)
    npm outdate -g(make sure there is some pkgs outdate), and found Latest field is not shown.
    image
windows

Most helpful comment

All node.js (or rather, libuv) does is call SetConsoleTextAttribute with the BACKGROUND_RED and BACKGROUND_BLUE attributes set. It's the responsibility of the console to display that as purple / magenta.

Since this is not a (libuv or node.js) bug and is not under our control I'll go ahead and close this. Perhaps you can file a bug report against powershell.

All 10 comments

For the npm issue, you should post about that on npm's issue tracker since they choose their own color scheme.

I can confirm this is an issue, but I am not sure what the proper fix is... There is only a limited number of colors and some other terminal might use another color as the default background, and so on.

You can use SET NODE_DISABLE_COLORS=1 before executing node to prevent this for the repl.

IMHO the bug is that magenta is mapped to #012456. When the BG is black it's Ok:
image

even more minimal snippent:

process.stdout.write(`\u001b[35mXXX\u001b[39m`)

image
AFAICT it's a Windows bug, since 35 should be magenta.

The powershell shortcut remaps magenta and dark yellow.
image

All node.js (or rather, libuv) does is call SetConsoleTextAttribute with the BACKGROUND_RED and BACKGROUND_BLUE attributes set. It's the responsibility of the console to display that as purple / magenta.

Since this is not a (libuv or node.js) bug and is not under our control I'll go ahead and close this. Perhaps you can file a bug report against powershell.

@yyjdelete FYI after playing around and discussing a possible code level fix, it seems like the simplest solution is to override the default style for dates with a statements similar to

util.inspect.styles.date = 'bold';
Was this page helpful?
0 / 5 - 0 ratings