Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用0.76.3版本,在现有原生项目中引入RN,报错:Could not read script 'D:\testRN\android\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' #915

Open
bywuuu opened this issue Nov 28, 2024 · 3 comments

Comments

@bywuuu
Copy link

bywuuu commented Nov 28, 2024

请按以下格式提供问题的相关信息。

问题的具体描述

我完全按照首页指南上的“集成到现有原生应用”那一章的做法做的,但是到了“执行"Sync Project files with Gradle"操作。”这一步操作的时候,我打开AndroidStudio,发现出现:Could not read script 'D:\testRN\android\node_modules@react-native-community\cli-platform-android\native_modules.gradle'这个错误,而且我打开文件夹目录,发现有也确实是没有这个native_modules.gradle文件。
我试验了npm i @react-native-community/cli-platform-android这个方法,但是还是没有这个文件。
image

请描述完整的环境/版本信息

System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
Memory: 6.08 GB / 15.93 GB
Binaries:
Node:RN\android>cd MyTest2
version: 20.18.0
path: C:\Program Files\nodejs\node.EXE info
Yarn:
version: 1.22.22
path: ~\AppData\Roaming\npm\yarn.CMD
npm:
version: 10.9.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "30"
- "34"
- "35"
Build Tools:
- 30.0.2
- 30.0.3
- 34.0.0
- 35.0.0
System Images:
- android-30 | Google APIs Intel x86 Atom
- android-33 | Google Play Intel x86_64 Atom
- android-34 | Intel x86_64 Atom
- android-35 | Google Play Experimental 16k Page Size Intel x86_64 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Not Found
Visual Studio:
- 17.11.35312.102 (Visual Studio Community 2022)
Languages:
Java: 17.0.13
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 15.1.2
wanted: ^15.1.2
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.76.3
wanted: ^0.76.3
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

  • 如果问题涉及到第三方包/库/模块,请也将 package.json 的内容粘贴到这里。
  • {
    "name": "MyReactNativeApp",
    "version": "0.0.1",
    "private": true,
    "scripts": {
    "start": "react-native start"
    },
    "dependencies": {
    "@react-native-community/cli": "^15.1.2",
    "@react-native-community/cli-platform-android": "^15.1.2",
    "react": "18.2.0",
    "react-native": "^0.76.3"
    }
    }
@sunnylqm
Copy link

你的settings.gralde跟node_modules同一层目录,路径却又写的上一层"../",那能找到吗

@sunnylqm
Copy link

你的目录结构如果和文档不一致,那就要做相应的调整啊

@liangtao125061github
Copy link

我也遇到了相同的问题。我从0.66.4升级到了0.72.14。
@react-native-community\cli-platform-android\native_modules.gradle' line: 389;
node:internal/modules/cjs/loader:1143 throw err; ^Error: Cannot find module 'react-native/cli'
找了好多方法都没解决

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

No branches or pull requests

3 participants