React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:

无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。

我做错了什么?


当前回答

对我有效的解决方案如下:

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

其他回答

请检查地铁服务器是否正在运行任何其他端口。如果有,停止所有服务器,然后重新启动服务器,再试一次。

默认情况下,一个名为“Metro server”的小型JavaScript服务器运行在端口8081上。

您需要使此端口可用于此服务器启动。所以,

释放端口 关闭虚拟设备 “react-native run-android”。

如何释放端口?

http://tenbull.blogspot.com/2019/05/how-to-kill-process-currently-using.html

如何在windows中杀死当前使用本地主机端口的进程?

最重要的是,我从8升级了我的节点版本。X到10.x(最新),正如facebook建议的那样 @ https://facebook.github.io/react-native/docs/getting-started

可能你的端口被占用了。 尝试在不同的端口上运行:

adb reverse tcp:6666 tcp:6666
react-native run-android --port 6666

检查您正在使用的端口是否空闲

linux:

lsof | grep LISTEN

窗口:

netstat -an

你还没有启动捆扎机呢。在项目的根目录下运行npm start或react-native start,然后再执行react-native Run -android。

试试这个命令

~/Library/Android/sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081