React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
当前回答
我的解决方案如下:
启动Metro服务器
$ react-native start
开始安卓
$ react-native run-android
如果看到错误提示“端口8081已被使用”,那么您可以终止该进程并重新运行
$ react-native start
参见React Native故障诊断页面。
其他回答
请检查地铁服务器是否正在运行任何其他端口。如果有,停止所有服务器,然后重新启动服务器,再试一次。
(快速回答)
在我的工作空间尝试解决这个问题后,我找到了一个解决方案。
此错误是因为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.
在数小时寻找答案之后。解决方案是将节点降级到版本12.4。
在我的例子中,我意识到这个错误只发生在节点版本12.6的react native 0.60版本中。
我经历过这种情况,只是因为我的模拟器错误地关闭了Wifi。我把它重新打开,它开始正常工作。希望对大家有所帮助
我的解决方案如下:
启动Metro服务器
$ react-native start
开始安卓
$ react-native run-android
如果看到错误提示“端口8081已被使用”,那么您可以终止该进程并重新运行
$ react-native start
参见React Native故障诊断页面。