React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
当前回答
我经历过这种情况,只是因为我的模拟器错误地关闭了Wifi。我把它重新打开,它开始正常工作。希望对大家有所帮助
其他回答
在数小时寻找答案之后。解决方案是将节点降级到版本12.4。
在我的例子中,我意识到这个错误只发生在节点版本12.6的react native 0.60版本中。
你还没有启动捆扎机呢。在项目的根目录下运行npm start或react-native start,然后再执行react-native Run -android。
(快速回答)
在我的工作空间尝试解决这个问题后,我找到了一个解决方案。
此错误是因为Metro使用NPM和Node版本的某些组合时出现了问题。
你有两个选择:
Alternative 1: Try to update or downgrade npm and node version. Alternative 2: Go to this file: \node_modules\metro-config\src\defaults\blacklist.js and change this code: var sharedBlacklist = [ /node_modules[/\\]react[/\\]dist[/\\].*/, /website\/node_modules\/.*/, /heapCapture\/bundle\.js/, /.*\/__tests__\/.*/ ]; and change to this: var sharedBlacklist = [ /node_modules[\/\\]react[\/\\]dist[\/\\].*/, /website\/node_modules\/.*/, /heapCapture\/bundle\.js/, /.*\/__tests__\/.*/ ]; Please note that if you run an npm install or a yarn install you need to change the code again.
在某些情况下,您可能需要关闭React-native捆绑器的端口 用相同的进程重新运行应用程序
1.sudo kill -9 $(sudo lsof -t -i:9001)
2.npm start inside the project
3. react-native run-android
你可以尝试以下方法:
在AndroidManifest.xml中添加这一行
<application
[...]
android:usesCleartextTraffic="true"
/>
[...]
</application>
编辑: 注意,为了应用程序的安全性,在生产环境中它必须为假