Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get more then handful of colors in iTerm2 (3.2.7) #682

Closed
jirikrepl opened this issue Feb 6, 2019 · 10 comments
Closed

Can't get more then handful of colors in iTerm2 (3.2.7) #682

jirikrepl opened this issue Feb 6, 2019 · 10 comments
Labels
awaiting-response This issue or pull request is awaiting a user's response

Comments

@jirikrepl
Copy link

I am using iTerm 3.2.7 can display 16M color, but debug-module will display only 16 colors.

This perl script can test color support in terminal: https://github.com/robertknight/konsole/blob/master/tests/color-spaces.pl
(source: https://apple.stackexchange.com/q/190167/265202)

Thank you for your help.

screen shot 2019-02-06 at 11 58 23

screen shot 2019-02-06 at 11 58 28

screen shot 2019-02-06 at 11 57 06

screen shot 2019-02-06 at 11 58 51

my debug test script:

const supportsColor = require('supports-color');

if (supportsColor.stdout) {
    console.log('Terminal stdout supports color');
}

if (supportsColor.stdout.has256) {
    console.log('Terminal stdout supports 256 colors');
}

if (supportsColor.stderr.has16m) {
    console.log('Terminal stderr supports 16 million colors (truecolor)');
}

const e1 = require('debug')('jest:1');
const e2 = require('debug')('jest:2');
const e3 = require('debug')('jest:3');
const e4 = require('debug')('jest:4');
const e5 = require('debug')('jest:5');
const e6 = require('debug')('jest:6');
const e7 = require('debug')('jest:7');
const e8 = require('debug')('jest:8');
const e9 = require('debug')('jest:9');
const e10 = require('debug')('jest:10');
const e11 = require('debug')('jest:11');
const e12 = require('debug')('jest:12');
const e13 = require('debug')('jest:13');
const e14 = require('debug')('jest:14');
const e15 = require('debug')('jest:15');
const e16 = require('debug')('jest:16');
const e17 = require('debug')('jest:17');
const e18 = require('debug')('jest:18');

e1('test');
e2('test');
e3('test');
e4('test');
e5('test');
e6('test');
e7('test');
e8('test');
e9('test');
e10('test');
e11('test');
e12('test');
e13('test');
e14('test');
e15('test');
e16('test');
e17('test');
e18('test');
@Qix-
Copy link
Member

Qix- commented Feb 6, 2019

npm install supports-color

Relevant: #612

@jirikrepl
Copy link
Author

Thank you for your quick answer. I think that I have supports-color module already installed. If you a look at my test script and then on the screenshot of what this script produces. (I think my script wouldn't work without supports-color module installed)

@Qix-
Copy link
Member

Qix- commented Feb 7, 2019

Yes but it needs to be install alongside debug (as a sibling dependency). Is that the case? Can you post your dependencies block from your package.json?

@Qix- Qix- added the awaiting-response This issue or pull request is awaiting a user's response label Feb 7, 2019
@samism
Copy link

samism commented Feb 7, 2019

I am also having this issue. I have installed supports-color as a sibling dependency.

  "dependencies": {
    "app-root-path": "^2.1.0",
    "axios": "^0.18.0",
    "body-parser": "^1.18.3",
    "cheerio": "^1.0.0-rc.2",
    "cookie-parser": "~1.4.3",
    "debug": "^2.6.9",
    "dotenv": "^6.2.0",
    "express": "~4.16.0",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "morgan": "~1.9.0",
    "multer": "^1.4.1",
    "soap": "^0.25.0",
    "supports-color": "^6.1.0",
    "xlsx": "^0.14.1"
  },

@samism
Copy link

samism commented Feb 7, 2019

    "debug": "^2.6.9"

Nevermind, I'm an idiot.

@jirikrepl
Copy link
Author

Hi, I had the same problem I had an old version of debug installed (3.1.0)

Not it works great for me!

"dependencies": {
    ...
    "debug": "^4.1.1",
    "supports-color": "^6.1.0",
    ...
}

screen shot 2019-02-08 at 11 16 01

@Qix-
Copy link
Member

Qix- commented Feb 8, 2019

Glad it got resolved :)

@Qix- Qix- closed this as completed Feb 8, 2019
@jirikrepl
Copy link
Author

jirikrepl commented Feb 8, 2019

Unfortunately for me, those colors work only if I do npm run dev

but we use pm2 also on development to run all backend microservices.

If I do pm2 log I see only a few colors again:(

screen shot 2019-02-08 at 12 42 17

I tried to google the issue quickly. But can't find what's the problem.
I tried pm2 log --raw but still, just a few colors

EDIT:
If I evaluate this code with pm2 log

const supportsColor = require('supports-color');

console.log('--------');
console.log(supportsColor);
console.log('--------');

if (supportsColor.stdout) {
    console.log('Terminal stdout supports color');
}

if (supportsColor.stdout.has256) {
    console.log('Terminal stdout supports 256 colors');
}

if (supportsColor.stderr.has16m) {
    console.log('Terminal stderr supports 16 million colors (truecolor)');
}

I see this log:

2019-02-08 12:48:54: --------
2019-02-08 12:48:54: { supportsColor: [Function: getSupportLevel],
  stdout: false,
  stderr: false }
--------

I also reported this issue here: Unitech/pm2#4155

@Qix-
Copy link
Member

Qix- commented Feb 8, 2019

This is a well known problem that isn't really an 'issue' per se. Pm2 would have to allocate a pseudo terminal. This is just how terminals work.

@lagden
Copy link

lagden commented Feb 28, 2024

Now, the problem is the supports-color with the version above 8.
Only works with type module, so keep you package.json like this until show up some security problem or @Qix- update to esm:

{
  "peerDependencies": {
    "debug": ">= 4 < 5",
    "supports-color": ">= 8 < 9"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-response This issue or pull request is awaiting a user's response
Development

No branches or pull requests

4 participants