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

ANSI color codes in chrome console output #837

Closed
xcoderzach opened this issue Feb 19, 2015 · 13 comments
Closed

ANSI color codes in chrome console output #837

xcoderzach opened this issue Feb 19, 2015 · 13 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@xcoderzach
Copy link

I'm getting this in my chrome console on error

Module build failed: SyntaxError: Unterminated JSX contents (266:12)
  264    |           �[1m�[37m<�[39m�[22m/�[37mdiv�[39m�[1m�[37m>�[39m�[22m
  265    |         �[1m�[37m<�[39m�[22m/�[37mdiv�[39m�[1m�[37m>�[39m�[22m
> 266    |       �[1m�[37m<�[39m�[22m/�[37mdiv�[39m�[1m�[37m>�[39m�[22m
         |             ^
  267    |     �[1m�[34m)�[39m�[22m
  268    |   �[32m}�[39m
  269    | �[32m}�[39m�[1m�[34m)�[39m�[22m
@sebmck
Copy link
Contributor

sebmck commented Feb 19, 2015

Can I have some more information, what plugin you're using etc?

@xcoderzach
Copy link
Author

  • Babel 4.3.0
  • babel loader 4.0.0
  • react hot loader 1.0.7

Using webpack these loaders

      {
        test: /\.js$/,
        exclude: /node_modules/,
        loaders: ['react-hot', 'babel?experimental=true,modules=common']
      },

and this plugin

webpack.NoErrorsPlugin()

@sebmck
Copy link
Contributor

sebmck commented Feb 20, 2015

There's not really anything that can be done besides removing the ANSI syntax highlighting altogether.

@xcoderzach
Copy link
Author

Is this default behavior, or is it due to some part of my configuration?

@sebmck
Copy link
Contributor

sebmck commented Feb 20, 2015

It's default behaviour. It automatically ANSI syntax highlights if the terminal supports-colors. You should be able to disable the colors with the following command:

$ TERM=dumb INSERT_YOUR_COMMAND_HERE

@xcoderzach
Copy link
Author

I really like the terminal colors :-D , so I think I'll just patch my console.error to strip ansi with https://github.com/sindresorhus/strip-ansi

Thanks for your help!

@sebmck
Copy link
Contributor

sebmck commented Feb 20, 2015

Ah great, no problem!

@marijnh
Copy link
Contributor

marijnh commented Mar 11, 2015

This problem still exists, and I don't think expecting users to use strip-ansi is a real solution. Could you reopen this issue?

@sebmck
Copy link
Contributor

sebmck commented Mar 11, 2015

Just thought of a way I could make it work:

err.stack = {
  inspect: function () { return coloredStack; },
  toString: function () { return noncoloredStack; },
  toJSON: function () { return noncoloredStack; }
};

Will dump colored output for the console but if it's serialised it'll be a non-colored string. Only issue is consumers that expect err.stack to be a string.

@sebmck
Copy link
Contributor

sebmck commented Mar 11, 2015

It's really hacky so I'll have to do some testing to see if it's practical. I'm hesitant on adding an additional option if it can be done some other (albeit hacky) way.

@sebmck sebmck closed this as completed in 1fb877e Mar 15, 2015
@sebmck
Copy link
Contributor

sebmck commented Mar 15, 2015

In the next release you'll be able to set the highlightErrors option to false.

@frederickfogerty
Copy link

👍

@joliss
Copy link
Contributor

joliss commented Mar 27, 2015

Chiming in on an old issue... How about having err.message be always non-colorized (so other tools can easily log and display them), but adding a seperate err.colorMessage (or ansiColorMessage) so consumers can decide whether what to print into their terminals?

Consuming apps like ember-cli would seem to be better-equipped to know whether to print color (e.g. by parsing a --color={always,auto,never} argument). The chalk library that babel uses calls this argv sniffing code to automagically turn color on and off - that seems like it's going to be brittle.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 24, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

5 participants