javascript Metro Bundler 遇到内部错误,请检查您的终端错误输出以了解更多详细信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48628105/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 08:08:38  来源:igfitidea点击:

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

javascriptreactjsreact-nativereact-reduxreact-android

提问by SameerShaik

after checkout when i say react-native run-android im getting below error.

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

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

below is package.json in my project.

下面是我的项目中的 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"
    }
}

anyone had this issue and solved it?

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

回答by Manish

Do you have any require image like this:

你有这样的需求图片吗:

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

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

If yes then please check the image path. I'm facing the same issue, so I just corrected the path and the error is gone.

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

回答by civani mahida

1.I suggest restarting React. Just run the following commands:

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

That should do the trick.

这应该够了吧。

2.If it is not working then check your image path you have used. For example

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

 <Image 
  source={require("./images/logo.png")} // check your image path you have used
>

回答by Sharath Vadlamannati

run these commands

运行这些命令

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

and this command too

还有这个命令

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

then run

然后运行

npm i && react-native run-android

or run-ios anything that is applicable

或 run-ios 任何适用的东西

回答by Edison Biba

I have faced this issue and here is how I fixed it.

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

If you are sure that there is nothing wrong with your code you can try to restart process in port 8081.

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

Open your terminal and find process id with below command:

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

sudo lsof -n -i :8081 | grep LISTEN

Then use kill idwhere idis returned from lsof

然后使用从kill id哪里id返回lsof

After that just run you application

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

react-native run-android

回答by santosh gawade

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.

我遇到了同样的问题。就我而言,基本上,这是因为导入语句中有一些损坏/错误的路径。在更正所有导入路径(即样式、组件、路由器、减速器、动作等)后,问题得到解决,重新启动模拟器并再次运行构建。

回答by q3e

Try removing "react-native-vector-icons": "^4.0.0"

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

This issue might help you with possible solutions

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