TypeError: Cannot read properties of undefined (reading 'bold')
duckytutorials opened this issue · 7 comments
When i do
chalk.bold.red or chalk.red.bold its broken
i m on v4.1.2 as i use common js
its broken
You need to show us your
- Code (including the
chalk
import) package.json
node --version
npm --version
- The error message - and if there is no error message, please state "there is no error message" and tell us the intended output vs the output you're seeing.
- Screenshots if it's a coloring issue
- The output of
echo $TERM
on non-Windows machines - Which terminal emulator (cmd.exe, iTerm2, xterm, etc.) you're using.
There's literally nothing I can do to help you without the above information because chalk.red.bold
works for millions of other people.
Issues like this usually come from an incorrectly configured bundler.
Yeah. Going to close for now as this is almost certainly not an issue with Chalk. Please let me know if that's not the case and we can re-open if need be.
Not sure if this is what OP saw, but:
All properties seem to be undefined when stdout is not a tty (including e.g. chalk.stderr).
Code:
import chalk from 'chalk-template';
console.warn(chalk.stderr.red.bold`An error`);
No bundler, in rollup.config.mjs
Because you're using chalk-template
. That's not how it works.
import chalk from 'chalk-template';
console.warn(chalk`{bold.red An error}`);
@Qix- it works normally, and I was expecting the chalk-template
package to still allow regular usage (maybe mixing styles isn't good style, but it will happen).
Also how am I supposed to use chalk.stderr
from chalk-template
? It's still the same error.
I don't think we have a way, come to think of it. Feel free to open an issue on chalk-template
.