You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
react-native.config.ts fails to load next to TypeScript 7: cli-config still depends on cosmiconfig 9 #2885
21.0.0-alpha.1 is the next release, published from main at f4c4ef3; 20.2.0 (latest) has the same cosmiconfig range.
Description
In a project with TypeScript 7, every CLI command fails with Failed to load configuration of your project. when the project's config is react-native.config.ts.
@react-native-community/cli-config depends on cosmiconfig^9.0.0 (packages/cli-config/package.json). cosmiconfig 9's .ts loader calls typescript.findConfigFile and transpileModule from the project's typescript, and TypeScript 7's package no longer ships that compiler API. cosmiconfig 10 loads .ts configs with Node's own TypeScript support instead (cosmiconfig/cosmiconfig#350, released in 10.0.0).
Expected: react-native.config.ts loads next to TypeScript 7, as it does next to TypeScript 5, and .js, .cjs and .mjs configs keep loading as they do now. With "overrides": { "cosmiconfig": "10.0.1" } in the same project, rnc-cli config prints the config.
Clone the gist and run bash repro.sh: it runs npm install, prints the versions it loaded, then runs npx rnc-cli config --verbose.
Expected: the config, with "./assets/fonts-from-the-ts-config" under assets; the script then exits 0.
Actual: the command exits 1 and the script exits 1:
rnc-cli config exited 1:
error Failed to load configuration of your project.
typescript.findConfigFile is not a function
verdict: the CLI failed to load react-native.config.ts beside typescript 7
The full error starts with TypeError: TypeScript Error in <project>/react-native.config.ts: and its stack is at resolveTsConfig in cosmiconfig/dist/loaders.js, from readConfigFromDiskAsync in @react-native-community/cli-config.
Hi, I'd like to take this. I can reproduce the failure.
One catch with the cosmiconfig 10 bump: it requires Node ^22.18 || >=24, while this repo declares >=20.19.4 in packages/cli/package.json and CI runs the tests on Node 20 and 22. A plain bump would drop Node 20.
Would you rather:
(a) bump to cosmiconfig 10 and raise the supported Node floor, or
(b) keep cosmiconfig 9 and add a .ts loader in packages/cli-config/src/readConfigFromDisk.ts that uses typescript when its compiler API exists and otherwise falls back to Node's native TypeScript loading (with a clear error on Node versions that can't do it)?
I'll start on (b) locally unless you prefer (a), and won't open a PR before hearing back.
Activity
nihar777 commentedon Nov 20, 2026
Hi, I'd like to take this. I can reproduce the failure.
One catch with the cosmiconfig 10 bump: it requires Node
^22.18 || >=24, while this repo declares>=20.19.4inpackages/cli/package.jsonand CI runs the tests on Node 20 and 22. A plain bump would drop Node 20.Would you rather:
(a) bump to cosmiconfig 10 and raise the supported Node floor, or
(b) keep cosmiconfig 9 and add a
.tsloader inpackages/cli-config/src/readConfigFromDisk.tsthat usestypescriptwhen its compiler API exists and otherwise falls back to Node's native TypeScript loading (with a clear error on Node versions that can't do it)?I'll start on (b) locally unless you prefer (a), and won't open a PR before hearing back.
nihar777 commentedon Nov 20, 2026
I opened a PR with the fallback loader approach (b): #2897. Happy to switch to a cosmiconfig 10 bump and a higher Node floor if you prefer that.