Skip to content

fix(cli): fix undeclared chalk dependency - #2819

Merged
Tommy Nguyen (tido64) merged 3 commits into
mainfrom
tido/fix-missing-chalk
Jan 22, 2026
Merged

fix(cli): fix undeclared chalk dependency#2819
Tommy Nguyen (tido64) merged 3 commits into
mainfrom
tido/fix-missing-chalk

Conversation

@tido64

Copy link
Copy Markdown
Member

Summary:

macOS bundling fails because it tries to import chalk but does not declare it.

/~/packages/app/example/node_modules/react-native-macos/react-native.config.js: node:internal/modules/cjs/loader:1421
  const err = new Error(message);
              ^

Error: Cannot find module 'chalk'
Require stack:
- /~/node_modules/.store/react-native-macos-virtual-89732d1908/package/local-cli/runMacOS/runMacOS.js
- /~/node_modules/.store/react-native-macos-virtual-89732d1908/package/react-native.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1421:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
    at Module._load (node:internal/modules/cjs/loader:1227:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
    at Module.require (node:internal/modules/cjs/loader:1504:12)
    at require (node:internal/modules/helpers:152:16)
    at Object.<anonymous> (/~/node_modules/.store/react-native-macos-virtual-89732d1908/package/local-cli/runMacOS/runMacOS.js:38:15)
    at Module._compile (node:internal/modules/cjs/loader:1761:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/~/node_modules/.store/react-native-macos-virtual-89732d1908/package/local-cli/runMacOS/runMacOS.js',
    '/~/node_modules/.store/react-native-macos-virtual-89732d1908/package/react-native.config.js'
  ]
}

Instead of adding chalk as a dependency (and introducing a diff), we inline the functions we use.

Test Plan:

n/a

@tido64
Tommy Nguyen (tido64) merged commit b9dde72 into main Jan 22, 2026
15 checks passed
@Saadnajmi
Saad Najmi (Saadnajmi) deleted the tido/fix-missing-chalk branch January 22, 2026 21:03
Saad Najmi (Saadnajmi) pushed a commit to Saadnajmi/react-native-macos that referenced this pull request Jan 22, 2026
## Summary:

macOS bundling fails because it tries to import `chalk` but does not
declare it.

```
/~/packages/app/example/node_modules/react-native-macos/react-native.config.js: node:internal/modules/cjs/loader:1421
  const err = new Error(message);
              ^

Error: Cannot find module 'chalk'
Require stack:
- /~/node_modules/.store/react-native-macos-virtual-89732d1908/package/local-cli/runMacOS/runMacOS.js
- /~/node_modules/.store/react-native-macos-virtual-89732d1908/package/react-native.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1421:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
    at Module._load (node:internal/modules/cjs/loader:1227:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
    at Module.require (node:internal/modules/cjs/loader:1504:12)
    at require (node:internal/modules/helpers:152:16)
    at Object.<anonymous> (/~/node_modules/.store/react-native-macos-virtual-89732d1908/package/local-cli/runMacOS/runMacOS.js:38:15)
    at Module._compile (node:internal/modules/cjs/loader:1761:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/~/node_modules/.store/react-native-macos-virtual-89732d1908/package/local-cli/runMacOS/runMacOS.js',
    '/~/node_modules/.store/react-native-macos-virtual-89732d1908/package/react-native.config.js'
  ]
}
```

Instead of adding `chalk` as a dependency (and introducing a diff), we
inline the functions we use.

## Test Plan:

n/a
Saad Najmi (Saadnajmi) added a commit that referenced this pull request Jan 22, 2026
## Summary:

Backport #2820 
Backport #2819 

## Test Plan:

CI should pass

---------

Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants