我有一个react-native项目,它在本地机器上运行良好,我把这个项目推到仓库,但是在另一台机器上构建失败。
所以我从另一台机器上的存储库中克隆了这个项目:
做了npm-install
然后我尝试了X1 M1 N1 X,但它缺少4个“打开Android应用程序”的选择,相反,它只显示两个(没有iOS和Android),所以我尝试了X1 M2 N1 X,但它失败了
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.facebook.react:react-android:.
Required by:
project :app
> Could not find com.facebook.react:hermes-android:.
Required by:
project :app
如果我删除node_modules
(Git忽略了它)文件夹,并从第一台本地计算机复制node_modules
,那么它可以正常工作,npx react-native start
检测ios和Android应用程序可以编译它们。
perk_sample.json的内容:
{
"name": "nameofapp",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"prop-types": "^15.8.1",
"react": "18.1.0",
"react-native": "0.70.2"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.19.0",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "0.72.3",
"react-test-renderer": "18.1.0"
},
"jest": {
"preset": "react-native"
}
}
请问我到添加任何其他信息如果需要
1条答案
按热度按时间yh2wf1be1#
我根据https://stackoverflow.com/a/74436820/7767664中的信息使用
npx react-native upgrade
升级了RN现在是
现在
npx react-native start
工作正常,我可以看到4个选择,它的建设以及(虽然不是从第一次尝试后,所有的操纵,重新运行帮助,但再次尝试清洁建设和工程从第一次尝试)很高兴我是一个本地开发人员,这只是一个临时项目:)
还有一个问题是,我排除了
gradle-wrapper.jar
(已添加到gitignore
),react-native无法使用gradle自行下载(尽管Android Studio不需要存储库中的此文件,但它可以使用gradle基于gradle-wrapper.properties
的URL自行下载):