【问题标题】:How to run react-native for windows? I have a problem: npx react-native run-android error如何为 Windows 运行 react-native?我有一个问题:npx react-native run-android 错误
【发布时间】:2021-07-05 05:13:11
【问题描述】:

我想运行 React Native 项目。我已经尝试过这个命令; npx react-native run-android 和。我试图解决所有错误,但仍然无法运行该项目。这是错误输出。

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

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 205

* What went wrong:
A problem occurred evaluating script.
node:internal/modules/cjs/loader:927
  throw err;
  ^Error: Cannot find module 'C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\@react-native-community\cli\build\bin.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)  
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module: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.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\@react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.

FAILURE: Build failed with an exception.

Script 'C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 205

* What went wrong:
A problem occurred evaluating script.
node:internal/modules/cjs/loader:927
  throw err;
  ^Error: Cannot find module 'C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\@react-native-community\cli\build\bin.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {  code: 'MODULE_NOT_FOUND',  requi
* 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

    at makeError (C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\execa\index.js:174:9)
    at C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\execa\index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async runOnAllDevices (C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
    at async Command.handleAction (C:\Users\batuh\OneDrive\Masaüstü\native\androidApp\node_modules\@react-native-community\cli\build\index.js:186:9)
info Run CLI with --verbose flag for more details.

【问题讨论】:

  • 我只是猜测有用的消息布局 - 请不要犹豫,在代码围栏之间重新开始复制​​和粘贴(只有 ~~~ 的行)。

标签: javascript node.js react-native android-studio react-native-android


【解决方案1】:

面对同样的问题,我注意到我们的错误中的共同点是:

  • 项目所在路径中有UTF-8 字符üC:\Users\batuh\OneDrive\Masaüstü\native\androidApp>

这意味着它在构建过程中的某处没有 utf-8 编码。


解决方案:将您的项目移动到没有这些字符的路径

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-16
    • 2023-02-22
    • 1970-01-01
    • 2021-02-14
    • 2020-12-29
    • 2020-07-27
    • 1970-01-01
    • 2019-06-26
    相关资源
    最近更新 更多