“无法从资产'index.android.bundle'加载脚本。请确保...”

时间:2019-10-31 20:24:30

标签: android react-native metro-bundler

似乎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

package.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 Emulator S8 Galaxy

1 个答案:

答案 0 :(得分:0)

我在以下情况下得到了解决方案:

  

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

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

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

Link from Stack Overflow here

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

npm i -g jetifier
npx jetify

Link here from GitHub

我希望它能对某人有所帮助。

向社区致敬。