Skip to content

Conversation

@tido64
Copy link
Member

@tido64 tido64 commented 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

@tido64 tido64 force-pushed the tido/fix-missing-chalk branch from ed64ffe to f698eef Compare January 22, 2026 18:17
@tido64 tido64 enabled auto-merge (squash) January 22, 2026 18:18
@tido64 tido64 merged commit b9dde72 into main Jan 22, 2026
15 checks passed
@Saadnajmi Saadnajmi deleted the tido/fix-missing-chalk branch January 22, 2026 21:03
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
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.

3 participants