1

似乎 Metro Bundler 没有加载......它正在打开和关闭,我看不到在关闭之前没有任何东西在里面运行。出于这个原因,模拟器没有运行应用程序。

运行后出现错误:

反应原生初始化项目

react-native run-android

**System:**
    OS: Windows 10
    CPU: (2) x64 AMD A4-6300 APU with Radeon(tm) HD Graphics
    Memory: 1.49 GB / 7.21 GB
  Binaries:
    Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.19.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD
  SDKs:
    Android SDK:
      API Levels: 23, 27, 28
      Build Tools: 23.0.1, 27.0.3, 28.0.3
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5900203
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.3 => 0.61.3

包.json

{
  "name": "first_app",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "16.9.0",
    "react-native": "0.61.3"
  },
  "devDependencies": {
    "@babel/core": "^7.6.4",
    "@babel/runtime": "^7.6.3",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.6.0",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.3",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Genymotion 模拟器 S8 银河

4

1 回答 1

0

之后我得到了解决方案:

用这个替换代码。文件的路径是 -

node_modules\metro-config\src\defaults\blacklist.js

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

来自 Stack Overflow 的链接

并且还在根项目文件夹中运行以下命令:

npm i -g jetifier
npx jetify

来自 GitHub 的链接

我希望它可以帮助某人。

感谢社区。

于 2019-10-31T20:29:09.857 回答