gpt4 book ai didi

react-native - 运行react-native run android时无法识别Tterm 'react-native'

转载 作者:行者123 更新时间:2023-12-02 03:40:47 26 4
gpt4 key购买 nike

我需要帮助来构建我的 react 原生项目。我尝试过react-native run-android,但出现以下错误:

react-native : The term 'react-native' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ react-native run android
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (react-native:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

最佳答案

艾亚伊·开尔文

您将需要 Node、React Native 命令行界面、JDK 和 Android Studio。

我以为你有,开发操作系统:Linux,目标操作系统:Android

节点 https://nodejs.org/en/download/package-manager/

React Native CLI

npm install -g react-native-cli

Java 开发工具包 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Android开发环境 https://developer.android.com/studio/index.html

守望者(可选) https://facebook.github.io/watchman/docs/install.html#buildinstall

创建新应用程序

$ react-native init AwesomeProject

$ cd AwesomeProject

$ react-native run-android

注意:如果您收到如下错误:“无法在真实设备上从 Assets 'index.android.bundle'加载脚本”

那么,(如果没有创建的话)将目录创建为 android/app/src/main/assets

低于 < 0.46 的旧 React Native 版本

$ react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

那么,

$ react-native run-android

关于react-native - 运行react-native run android时无法识别Tterm 'react-native',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48704721/

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