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

chalk.hex is not a function #34

Open
2 tasks done
tiagorangel1 opened this issue Jun 1, 2024 · 1 comment
Open
2 tasks done

chalk.hex is not a function #34

tiagorangel1 opened this issue Jun 1, 2024 · 1 comment

Comments

@tiagorangel1
Copy link

  • I have the latest versions of all packages
  • I am using the demo code
import chalkAnimation from 'chalk-animation';

chalkAnimation.rainbow('Lorem ipsum dolor sit amet');
$ bun run test.js
19 |    const options = validateOptions(opts);
20 |    const colorsCount = Math.max(str.replace(forbiddenChars, '').length, gradient.stops.length);
21 |    const colors = getColors(gradient, options, colorsCount);
22 |    let result = '';
23 |    for (const s of str) {
24 |            result += s.match(forbiddenChars) ? s : chalk.hex(colors.shift().toHex())(s);
                                               ^
TypeError: chalk.hex is not a function. (In 'chalk.hex(colors.shift().toHex())', 'chalk.hex' is undefined)
      at applyGradient (C:\Users\xxxx\node_modules\gradient-string\index.js:24:43)    
      at ret (C:\Users\xxxx\node_modules\gradient-string\index.js:10:80)
      at map (:1:21)
      at frame (C:\Users\xxxx\node_modules\chalk-animation\index.js:154:59)
      at render (C:\Users\xxxx\node_modules\chalk-animation\index.js:145:8)
      at start (C:\Users\xxxx\node_modules\chalk-animation\index.js:167:4)
      at C:\Users\xxxx\node_modules\chalk-animation\index.js:173:4
@RahulYavvari
Copy link

Have you bun add chalk 'ed?
Then try, import chalk from 'chalk';

Because, chalk.hex if a function in chalk package.

Assuming colors.shift().toHex() return a hex color string, it should work with the chalk package added and imported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants