-
Notifications
You must be signed in to change notification settings - Fork 927
Description
Ask your Question
-
Summary of the Problem:
"I am consistently encountering an issue where the scripts/gradle/codegen.gradle file (and the scripts folder itself) is missing from the node_modules/@react-native/codegen package after running npx react-native init for any React Native version. This prevents react-native run-android from building, failing with Could not find scripts/gradle/codegen.gradle or similar errors." -
Detailed Description of Steps Taken & Observations:
Initial Environment (Windows 10/11):
Node.js Version: [v18.19.0]
NPM Version: [ 10.8.2]
React Native Versions Tested: 0.73.10, 0.74.7, and latest (no --version specified).
Reproduction Steps:
Created new React Native project: npx react-native init MyProject --version [0.74.7]
cd MyProject
npm install (this happens automatically with init)
Attempted to build: npx react-native run-android
Observed Error: Build fails, indicating codegen.gradle or the scripts folder is missing in node_modules/@react-native/codegen.
Verification: dir node_modules@react-native\codegen or dir node_modules@react-native\codegen\scripts\gradle shows scripts folder is absent, only lib, package.json, README.md are present.
Extensive Troubleshooting on Windows (and results):
Performed multiple comprehensive cleanups:
Deleted node_modules and package-lock.json.
Ran npm cache clean --force.
Deleted all Android build artifacts (.cxx, app/build, app/.gradle, etc.).
Manually cleared global Gradle caches (C:\Users....gradle\caches, wrapper).
Re-ran npm install. Result: No change, scripts folder still missing.
Attempted to isolate @react-native/codegen direct installation:
npm install @react-native/codegen@latest --verbose into a dummy project. Result: scripts folder still missing.
Temporarily disabled Antivirus/Windows Defender real-time protection, ransomware protection. Result: No change, scripts folder still missing after clean reinstall.
Checked npm doctor and npm cache verify. Result: No critical errors reported.
Checked network/proxy settings in npm config. Result: No unusual settings.
Cross-Environment Test (Chromebook Linux (Beta)):
Environment: Freshly set up Crostini (Debian Linux).
Node.js Version: v18.19.0
NPM Version: 9.2.0
Reproduction Steps (same as Windows):
npx react-native init ChromebookTestApp --version 0.74.7
cd ChromebookTestApp
Observed Result: ls -l node_modules/@react-native/codegen/scripts/gradle returns No such file or directory. The scripts folder is also missing here, just like on Windows.
Verification: ls -l node_modules/@react-native/codegen shows lib, package.json, README.md, but no scripts folder.
Attempted Yarn: npx react-native init YarnTestApp --version 0.74.7 --npm false. Result: scripts folder still missing.
-
Request for Help:
"Has anyone else encountered this? Is there a known issue with the @react-native/codegen package or npx react-native init that could cause this? What further diagnostics can I run to pinpoint why this specific folder is always missing?" -
Environment Details:
OS (Windows): [Windows 10 Pro, Version 22H2]
OS (Chromebook): [Chromebook model, ChromeOS ]
React Native CLI Version (from npx react-native --version on both): dependencies": {
"react": "18.2.0",
"react-native": "0.74.7"
},
Android Studio Version: [If applicable, e.g., Flamingo 2022.2.1 Patch 2]
Node.js Version: v18.19.0