出现错误 - 运行本机反应时无法识别的命令“run-android”,

Posted

技术标签:

【中文标题】出现错误 - 运行本机反应时无法识别的命令“run-android”,【英文标题】:Getting error - Unrecognized command "run-android", when running react native, 【发布时间】:2020-02-20 11:39:30 【问题描述】:

尝试在我的模拟器上运行 react native 时出现此错误,react-native run-android

错误无法识别的命令“run-android”。

我的模拟器已连接并正常工作,有什么想法吗?

包.json:


  "name": "iaapp",
  "version": "0.0.1",
  "private": true,
  "scripts": 
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "name": "Inovative Anatomy",
    "flow": "flow",
    "test": "node ./node_modules/jest/bin/jest.js --watchAll"
  ,
  "dependencies": 
    "@babel/plugin-proposal-decorators": "^7.4.4",
    "@react-native-community/async-storage": "^1.6.1",
    "react": "16.8.5",
    "react-dom": "^16.8.6",
    "react-native": "0.59.10",
    "react-native-circular-progress": "^1.1.0",
    "react-native-component-fade": "^1.0.2",
    "react-native-elements": "^1.1.0",
    "react-native-fade": "^1.0.3",
    "react-native-fade-in-view": "^1.0.5",
    "react-native-gesture-handler": "^1.3.0",
    "react-native-responsive-image": "^2.3.1",
    "react-native-share": "^1.2.1",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^9.5.1",
    "react-native-vector-icons": "^6.6.0",
    "react-native-view-shot": "^2.6.0",
    "react-native-webview": "^5.12.1",
    "react-native-webview-bridge": "^0.40.1",
    "react-navigation": "^3.0.9",
    "react-navigation-backhandler": "^1.3.2",
    "react-navigation-transitions": "^1.0.11",
    "react-redux": "^6.0.1",
    "redux": "^4.0.1",
    "redux-persist": "^5.10.0",
    "redux-thunk": "^2.3.0"
  ,
  "devDependencies": 
    "@babel/cli": "^7.5.5",
    "@babel/core": "^7.5.5",
    "@babel/runtime": "^7.8.4",
    "@react-native-community/eslint-config": "^0.0.7",
    "@types/jest": "^24.0.18",
    "@types/react": "^16.9.2",
    "@types/react-native": "^0.60.14",
    "@types/react-redux": "^7.1.7",
    "@types/react-test-renderer": "^16.9.0",
    "@types/redux-logger": "^3.0.7",
    "@types/redux-persist": "^4.3.1",
    "babel-jest": "^24.1.0",
    "eslint": "^6.8.0",
    "jest": "^24.1.0",
    "metro-react-native-babel-preset": "0.54.1",
    "prettier": "^1.18.2",
    "react-native-dotenv": "^0.2.0",
    "react-test-renderer": "16.8.6",
    "redux-logger": "^3.0.6",
    "tslint-react": "^4.2.0",
    "typescript": "^3.6.3"
  ,
  "jest": 
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  

【问题讨论】:

这能回答你的问题吗? react-native run-android is unrecognized 【参考方案1】:

我遇到这个问题几分钟,直到我意识到我在错误的目录中运行命令...

我把它放在这里是希望这将帮助一些未来的开发者犯下类似的、简单的错误。

【讨论】:

【参考方案2】:

试试npx react-native run-android

【讨论】:

你可能使用@react-native-community/cli,请查看github.com/react-native-community/cli#about【参考方案3】:

如果“npx react-native run-android”不起作用转到“package.jason”文件 并查看“脚本”调试器是否存在。 单击调试器会在屏幕顶部为您提供选项。 选择“react-native run-android”。

【讨论】:

【参考方案4】:

您必须更新您的 npm 版本...使用此命令并重试...

npm install npm@latest -g

学分here

【讨论】:

以上是关于出现错误 - 运行本机反应时无法识别的命令“run-android”,的主要内容,如果未能解决你的问题,请参考以下文章

调用本机模块会引发“无法识别的 objc 方法”错误

调用本机模块会引发“无法识别的 objc 方法”错误

如何解决 [__NSCFString _isResizable] 的运行时错误:无法识别的选择器发送到实例?

mips64el-linux-android-g++:错误:无法识别的命令行选项“-mfpu=neon”

错误:无法识别的命令:服务

尝试在 Google Play 上发布我的应用程序时,第 20 行出现错误无法识别的 xmltree 行:'C:“”'