gpt4 book ai didi

react-native - react native 失败 : Build failed with an exception

转载 作者:行者123 更新时间:2023-12-03 04:54:41 26 4
gpt4 key购买 nike

我为在 Windows 上进行原生 react 进行了必要的设置。然后我使用命令“npx react-native init projectname”创建了我的项目。然后我使用“npx react-native run-android”命令运行我的项目,但出现以下错误。

C:\Users\user\OneDrive\Masaüstü\mobile\project>npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\user\OneDrive\Masaüstü\mobile\project\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\user\OneDrive\Masaüstü\mobile\project\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\user\OneDrive\Masaustu\mobile\project\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 195

* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:969 throw err; ^Error: Cannot find module 'C:\Users\user\OneDrive\Masaüstü\mobile\project\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15) at Function.Module._load (internal/modules/cjs/loader.js:842:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []}

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\user\OneDrive\Masaüstü\mobile\project\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js, config]' command.

C:\Users\user\OneDrive\Masaüstü\mobile\project>

最佳答案

首先,你必须安装最新版本的@react-native-community/cli-platform-android

npm i @react-native-community/cli-platform-android
然后转到android目录并通过以下命令清理gradlew
cd android && gradlew clean
返回主目录并运行应用程序
cd.. && react-native run-android

关于react-native - react native 失败 : Build failed with an exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62952708/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com