D:\ReactNative\AwesomeProject>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
:ReactNative:Cannot run program "npx": CreateProcess error=2, The system cannot find the file specified
:ReactNative:Automatic import of native modules failed.
FAILURE: Build failed with an exception.
Where: Script 'D:\ReactNative\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 169
What went wrong: A problem occurred evaluating script.
Cannot invoke method getErrorStream() on null object
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 1s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
Where: Script 'D:\ReactNative\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 169
What went wrong: A problem occurred evaluating script.
Cannot invoke method getErrorStream() on null object
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 1s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (D:\ReactNative\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Run Code Online (Sandbox Code Playgroud)
Hol*_*loW 18
对我来说,问题出在这个 cli 上:
@react-native-community/cli-platform-android
Run Code Online (Sandbox Code Playgroud)
有问题的版本:
3.0.0-alpha.7
Run Code Online (Sandbox Code Playgroud)
只需运行它来安装最新的稳定版本:
npm i @react-native-community/cli-platform-android@2.9.0
Run Code Online (Sandbox Code Playgroud)
2020 年更新:
如果此解决方法现在不起作用,请查看此链接以使用存储库中的最新版本,并查看您的 cli 版本以比较并使用正确的版本:
https://www.npmjs.com/package/@react-native-community/cli-platform-android
Run Code Online (Sandbox Code Playgroud)
在 linux 上有同样的问题。我所要做的就是将 npx 全局安装到我的机器上,仅此而已。
sudo npm install -g npx
这是因为 native_modules.gradle 中的第 155 和 159 行:
def command = "${npx} --quiet react-native config"
...
cmdProcess = Runtime.getRuntime().exec(command)
它尝试执行命令,但未找到命令 npx。
小智 2
我已经从旧项目中复制并替换了这个文件,现在它已经成功了。
node_modules@react-native-community\cli-platform-android\native_modules.gradle'
| 归档时间: |
|
| 查看次数: |
3258 次 |
| 最近记录: |