From 88c989b6474749339200655f38330d992a4bf7c5 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 22 Jan 2026 14:31:20 +0100 Subject: [PATCH 1/3] fix(cli): fix undeclared `chalk` dependency --- .../local-cli/runMacOS/runMacOS.js | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/react-native/local-cli/runMacOS/runMacOS.js b/packages/react-native/local-cli/runMacOS/runMacOS.js index e171d776937f63..9bda3f799ffc69 100644 --- a/packages/react-native/local-cli/runMacOS/runMacOS.js +++ b/packages/react-native/local-cli/runMacOS/runMacOS.js @@ -35,9 +35,24 @@ * }} ProjectConfig */ -const chalk = require('chalk'); -const child_process = require('child_process'); -const path = require('path'); +const child_process = require('node:child_process'); +const path = require('node:path'); + +const colors = (() => { + const {WriteStream} = require('node:tty'); + if (WriteStream.prototype.hasColors() && + !process.env['NODE_TEST_CONTEXT'] && + process.env['NODE_ENV'] !== 'test' + ) { + return { + bold: (s) => '\u001B[1m' + s + '\u001B[22m', + dim: (s) => '\u001B[2m' + s + '\u001B[22m', + } + } + + const passthrough = (s) => s; + return { bold: passthrough, dim: passthrough }; +})(); const {logger, CLIError, getDefaultUserTerminal} = (() => { const cli = require.resolve('@react-native-community/cli/package.json'); @@ -92,7 +107,7 @@ function parseArgs(ctx, args) { logger.info( `Found Xcode ${ xcodeProject.isWorkspace ? 'workspace' : 'project' - } "${chalk.bold(xcodeProject.name)}"`, + } "${colors.bold(xcodeProject.name)}"`, ); return {sourceDir, xcodeProject, scheme}; @@ -146,7 +161,7 @@ async function run(sourceDir, xcodeProject, scheme, args) { .trim(); logger.info( - `Launching app "${chalk.bold(bundleID)}" from "${chalk.bold(appPath)}"`, + `Launching app "${colors.bold(bundleID)}" from "${colors.bold(appPath)}"`, ); child_process.exec( @@ -179,7 +194,7 @@ function buildProject(sourceDir, xcodeProject, scheme, args) { scheme, ]; logger.info( - `Building ${chalk.dim( + `Building ${colors.dim( `(using "xcodebuild ${xcodebuildArgs.join(' ')}")`, )}`, ); From f698eef88a8ffbbc01ab64efd47fb8e2c2e583b1 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 22 Jan 2026 14:56:37 +0100 Subject: [PATCH 2/3] also resolve `@react-native-community/cli` from the correct path --- packages/react-native/local-cli/runMacOS/runMacOS.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/local-cli/runMacOS/runMacOS.js b/packages/react-native/local-cli/runMacOS/runMacOS.js index 9bda3f799ffc69..9b9b5df55d18d0 100644 --- a/packages/react-native/local-cli/runMacOS/runMacOS.js +++ b/packages/react-native/local-cli/runMacOS/runMacOS.js @@ -54,8 +54,8 @@ const colors = (() => { return { bold: passthrough, dim: passthrough }; })(); -const {logger, CLIError, getDefaultUserTerminal} = (() => { - const cli = require.resolve('@react-native-community/cli/package.json'); +const {logger, CLIError, getDefaultUserTerminal} = ((projectRoot = process.cwd()) => { + const cli = require.resolve('@react-native-community/cli/package.json', {paths: [projectRoot]}); const options = {paths: [path.dirname(cli)]}; const tools = require.resolve('@react-native-community/cli-tools', options); return require(tools); From b6db8ef3a0c7c33a5b85701b24244c32b7044f09 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 22 Jan 2026 20:04:44 +0100 Subject: [PATCH 3/3] use dot-notation --- packages/react-native/local-cli/runMacOS/runMacOS.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/local-cli/runMacOS/runMacOS.js b/packages/react-native/local-cli/runMacOS/runMacOS.js index 9b9b5df55d18d0..9fad4f6555c681 100644 --- a/packages/react-native/local-cli/runMacOS/runMacOS.js +++ b/packages/react-native/local-cli/runMacOS/runMacOS.js @@ -41,8 +41,8 @@ const path = require('node:path'); const colors = (() => { const {WriteStream} = require('node:tty'); if (WriteStream.prototype.hasColors() && - !process.env['NODE_TEST_CONTEXT'] && - process.env['NODE_ENV'] !== 'test' + !process.env.NODE_TEST_CONTEXT && + process.env.NODE_ENV !== 'test' ) { return { bold: (s) => '\u001B[1m' + s + '\u001B[22m',