8

结帐后,当我说 react-native run-android 时出现错误。

Metro Bundler has encountered an internal error, please check your terminal error output for more details

下面是我项目中的 package.json。

{
    "name": "NCAPRNRedux",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "dependencies": {
        "react": "16.2.0",
        "react-native": "0.52.2",
        "react-native-vector-icons": "^4.0.0",
        "react-navigation": "^1.0.0-beta.29",
        "react-redux": "^5.0.6",
        "redux": "^3.7.2",
        "redux-thunk": "^2.2.0"
    },
    "devDependencies": {
        "babel-jest": "22.1.0",
        "babel-plugin-transform-decorators-legacy": "^1.3.4",
        "babel-preset-react-native": "^4.0.0",
        "jest": "22.1.4",
        "react-test-renderer": "16.2.0"
    },
    "jest": {
        "preset": "react-native"
    }
}

有人遇到过这个问题并解决了吗?

4

6 回答 6

9

你有没有这样的需求图片:

require("../assets/user.png")

如果是,请检查图像路径。我面临同样的问题,所以我只是更正了路径,错误就消失了。

于 2019-02-22T10:49:32.107 回答
7

1.我建议重启 React。只需运行以下命令:

# Kill current processes
killall node -9 

# Start React - Native
react-native start 

# Run android
react-native run-android or  react-native run-ios

这应该够了吧。

2.如果它不起作用,请检查您使用的图像路径。例如

 <Image 
  source={require("./images/logo.png")} // check your image path you have used
>
于 2019-02-07T08:16:37.210 回答
3

运行这些命令

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

还有这个命令

rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json

然后运行

npm i && react-native run-android

或 run-ios 任何适用的

于 2018-03-08T10:14:21.730 回答
1

我遇到了这个问题,这就是我解决它的方法。

如果您确定您的代码没有问题,您可以尝试在端口 8081 中重新启动进程。

打开终端并使用以下命令查找进程 ID:

sudo lsof -n -i :8081 | grep LISTEN

然后使用kill idwhere idis return fromlsof

之后只需运行您的应用程序

react-native run-android
于 2019-03-21T10:11:48.447 回答
0

尝试删除 "react-native-vector-icons": "^4.0.0"

此问题可能会帮助您找到可能的解决方案

于 2018-03-08T09:36:43.000 回答
0

I`ve faced the same issue. In my case basically, it is because of some broken/wrong paths in imports statements. The issue gets solved after correcting all the imports paths i.e styles, components, routers, reducers, actions etc., restarting the emulator and running the build again.

于 2018-12-04T06:39:42.630 回答