Respect console's color settings (on Powershell on windows) #2381
Comments
What does |
1.1.16 from Node 0.6.15 |
1.1.24, same issue. |
@stdcall |
C:\Users\Nikolay> npm --versions |
Any update on this? No matter what I do, npm changes the colors to light grey with slightly lighter grey text, and it makes it almost impossible to read. |
I can't find a solution anywhere, so here's my slightly ghetto fix:
This doesn't fix node output, but at the very least it'll ensure that your colors are the same when you're finished. |
An alternative workaround is to disable the NPM colors with: |
This is still an issue in 1.3.21, why is this closed? |
I was curious about that. I've since bought a mac, but |
It doesn't just set the foreground to gray, it sets the background to black too. In a default PowerShell window (blue background), it looks really awful. Disabling colours is a workaround, but then you lose a lot of readability in the ouput of npm commands. |
Can't believe this isn't fixed yet. I'm working on mac, but sometimes I need to go back to windows, and this tiny two-years-old bug really annoys me. |
@arteezy pull request welcome! |
@othiym23 Any idea where in the code to start working on this? |
@stereokai Search for 'color.bg' in the source, my suspicion is that if you remove all of the color.bgBlack calls it'll fix the issue. Failing that, you'll have to patch the Though briefly inspecting http://en.wikipedia.org/wiki/ANSI_escape_code#graphics It's sending code 39 to restore foreground color and 49 to restore background color. That this is failing in powershell implies that powershell doesn't properly support ansi. =( It almost certainly supports 0 to restore EVERYTHING to the defaults, you'll just have to figure out how to issue that at the right time... |
For what it's worth, this isn't purely a PowerShell problem. I discovered the other day that if I customize my Command Prompt shortcut's colors, but then change the global Command Prompt colors, NPM will use the global colors. The colors are then permanently changed once NPM is done running.
|
@iarna There only 2 calls to I don't think these are the problem. Perhaps incorporating something like this could be a solution: |
👍 |
@iarna Any ideas (please see my previous comment) |
This was first reported in April 2012! Over three years and still no fix :( This bug is annoying. |
Just because you guys use Macs doesn't take away from how annoying this bug is. And even if this issue doesn't seem to broadcast significance to you, doesn't mean you should let this one fall between the cracks. After all it's your product, and If this behavior would have occurred on OSX terminals, I am absolutely confident this bug would have been dealt with a long time ago. 6 months ago I also said I am willing to invest my time into this and even posted a practical comment, which I quote here below:
Looking forward to your comment. |
Looking forward to pull requests from those complaining. |
What a poor attitude. Since when was "fixing bugs you find" a condition of using OSS? Why no appreciation for those taking time to report bugs to you and even do some investigation into the issue? |
Surely domenic is joking! O.0 |
Not at all. Complaining on an issue tracker is not very helpful in fixing the issue. This is a known issue, tagged with patch-welcome, and just complaining that the npm team has been working on other issues instead of the particular one you care about is very bad open source ettiquete, compared to actually contributing to the project. |
Thanks, with context, your previous post becomes understandable. My apologies, I was in a bad mood when I complained, I like my colours in PowerShell :) Will look and see if I can fix this damn thing. |
I think people are simply trying to express how frustrating this bug is, because it's clear it probably isn't affecting any of the contributors. Every time I use npm, I end up restarting PowerShell just to fix the colours. It makes npm seem unpolished and unloved.
I don't know, but I interpreted this comment:
as "I can't figure out where this could be coming from and need some pointers". Sometimes something that is trivial to debug to someone that's familiar with the code is not so for someone else. I'd love to have a go at fixing this but with limited time, it would probably take me a long time just to get the thing up and running in a way that would allow me to debug and investigate. Having the time, motivation or ability to fix something is not an advertised condition of using OSS but if that's how things are then maybe it should be made clear. Nothing worse than committing to a technology to find the author(s) will not fix any bugs you report and expect you to do it yourself. There is an assumption that an active OSS project will have bugs that affect large numbers of people fixed; it's not unreasonable for people to show their support for a case (especially in an issue tracker that has no good way to vote, like Google Issues had stars, to help prioritise cases). |
In the interest of keeping this positive and productive, I took a look at the code. After a brief perusal here, I suspect that this bug may need to be moved to the npmlog project. My guess is that the npmlog object should capture the current foreground and background colors upon its first interaction with the output stream, and be responsible for restoring them. Could one of the maintainers weigh in here, please? |
How about to make default value of |
👎 Once upon a time I put a powershell function into my |
And down the rabbit hole we go. I'm suspecting that the |
Thanks floyd, mcuh apprecaited. |
@DanTup 👍
Excuse me? Have you actually paid attention to my... "rant"? I wasn't only complaining (though rightfully so, and in stark contrast to you), I actually had a go at this 6 months ago and was looking for some pointers from people who actually know the code. Like you. I don't want to turn this into a personal thing or whatever. But you could might as well direct your comment about my "complaining, non-contributing attitude" to yourself.
Although not a fix to the bug, it's a very clever idea - well done!
That's what @iarna recommended me to look at last year. I have taken another thorough look at ansi, but I have a hunch that this is not where the problem is. I tend to lean towards her idea:
|
@stereokai In reference to this:
Here's an interesting tidbit from |
Updating to latest node version solves the issue |
I can confirm that this does not happen in PowerShell for me any more with a current Node.js. I'm going to close this as resolved. |
@iarna Thank you. |
@jarruda I'd recommend running the sample app above that uses the |
I use
npm
on Powershell, but npm changed the console's background color.The text was updated successfully, but these errors were encountered: