X Tutup
Skip to content

util.styleText() does not accept format aliases on Node.js >= 25.7.0 #62177

@bidord

Description

@bidord

Version

v25.7.0 - v25.8.0

Platform

Linux 12dcdbb287ef 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025 x86_64 GNU/Linux

Subsystem

util

What steps will reproduce the bug?

util.styleText("grey", "foo")

Node.js v25.6.1 ✅

$ docker run --pull=always --rm -itq node:25.6.1 -p 'util.styleText("grey", "foo")'
foo

Node.js v25.7.0 ❌

$ docker run --pull=always --rm -itq node:25.7.0 -p 'util.styleText("grey", "foo")'
node:internal/errors:546
      throw error;
      ^

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'format' must be one of: 'reset', 'bold', 'dim', 'italic', 'underline', 'blink', 'inverse', 'hidden', 'strikethrough', 'doubleunderline', 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'bgBlack', 'bgRed', 'bgGreen', 'bgYellow', 'bgBlue', 'bgMagenta', 'bgCyan', 'bgWhite', 'framed', 'overlined', 'gray', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright', 'whiteBright', 'bgGray', 'bgRedBright', 'bgGreenBright', 'bgYellowBright', 'bgBlueBright', 'bgMagentaBright', 'bgCyanBright', 'bgWhiteBright'. Received 'grey'
    at Object.styleText (node:util:209:7)
    at [eval]:1:6
    at runScriptInThisContext (node:internal/vm:219:10)
    at node:internal/process/execution:451:12
    at [eval]-wrapper:6:24
    at runScriptInContext (node:internal/process/execution:449:60)
    at evalFunction (node:internal/process/execution:283:30)
    at evalTypeScript (node:internal/process/execution:295:3)
    at node:internal/main/eval_string:71:3 {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v25.7.0

(Same result with latest 25.8.0)

How often does it reproduce? Is there a required condition?

Node.js >= 25.7.0

What is the expected behavior? Why is that the expected behavior?

Same behavior as with Node.js v25.6.1 and earlier.

According to documentation 'grey' should be a valid alias for 'gray'.

What do you see instead?

util.styleText() throws an error.

Additional information

Maybe related to #61792

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup