React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
当前回答
可能你的端口被占用了。 尝试在不同的端口上运行:
adb reverse tcp:6666 tcp:6666
react-native run-android --port 6666
检查您正在使用的端口是否空闲
linux:
lsof | grep LISTEN
窗口:
netstat -an
其他回答
默认情况下,一个名为“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
试试这个
taskkill /F /IM node.exe
然后
npx react-native run-android
对我有效的解决方案如下:
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
你还没有启动捆扎机呢。在项目的根目录下运行npm start或react-native start,然后再执行react-native Run -android。
在尝试了几种方法后,这对我来说很有效。
在文件node_modules\metro-config\src\defaults\blacklist.js中
替换:
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
:
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
希望这能有所帮助。