react-native icon indicating copy to clipboard operation
react-native copied to clipboard

In Node.js v21+, TypeError [ERR_INVALID_ARG_VALUE] from util.styleText()

Open jiangtao opened this issue 1 month ago • 4 comments

Description

The React Native development server fails to start on Node.js v21+ with the following 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 [ 'bold', 'inverse' ]

at styleText (node:util:210:5)
at attachKeyHandlers (/path/to/node_modules/@react-native/community-cli-plugin/dist/commands/start/attachKeyHandlers.js:91:25)

`

Steps to reproduce

  1. Steps to Reproduce
  2. Install Node.js v21.0.0 or higher
  3. Create a new React Native project or use existing one
  4. Run npx react-native start
  5. Observe the error

React Native Version

0.82.1

Affected Platforms

Other (please specify)

Output of npx @react-native-community/cli info

React Native version: 0.82.1
@react-native/community-cli-plugin version: 0.82.1
Node.js version: 21.7.3
Operating System: macOS 23.3.0

Stacktrace or Logs

`
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 [ 'bold', 'inverse' ]

    at styleText (node:util:210:5)
    at attachKeyHandlers (/path/to/node_modules/@react-native/community-cli-plugin/dist/commands/start/attachKeyHandlers.js:91:25)

MANDATORY Reproducer

https://github.com/jiangtao/react-native-in-node21

Screenshots and Videos

No response

jiangtao avatar Nov 17 '25 16:11 jiangtao

[!WARNING] Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


You can read more about about it on our website: How to report a bug.

react-native-bot avatar Nov 17 '25 16:11 react-native-bot

Warning

Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:

You can read more about about it on our website: How to report a bug.

add the Reproducer

jiangtao avatar Nov 18 '25 14:11 jiangtao

To solve this problem, there are two solutions:

  1. Use at least Node.js version 22 or higher.
  2. Adapt styleText to Node.js version 21, ensuring compatibility with version 22 parameters.

If the solution is confirmed, I can fix it.

@mojodna

jiangtao avatar Nov 27 '25 17:11 jiangtao

node_modules\@react-native\community-cli-plugin\dist\commands\start\attachKeyHandlers.js lines 91...93:

  ${(0, _util.styleText)("bold", (0, _util.styleText)("inverse", " r "))} - reload app(s)
  ${(0, _util.styleText)("bold", (0, _util.styleText)("inverse", " d "))} - open Dev Menu
  ${(0, _util.styleText)("bold", (0, _util.styleText)("inverse", " j "))} - open DevTools

bondarenkod avatar Dec 17 '25 10:12 bondarenkod