当我运行一个react-native项目时,我得到一个错误,没有bundle URL,但我不知道我做了什么错误,我很困惑。


当前回答

大多数情况下,此问题发生在DNS查找/ IP查找无法找到本地主机时。

解决方案:

尝试将localhost ip添加到etc主机文件中。

你可以在etc主机文件(/etc/hosts)中添加以下代码行

127.0.0.1 localhost

255.255.255.255 广播主机

::1升。ocalhost

要确认这就是问题所在 你可以在safari上点击bundle url(如果你在chrome中尝试,这将解决,但safari将无法解决它)。http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false

其他回答

以下步骤:

用xcode打开ios文件项目 在项目包中删除main。jsbundle文件 通过main添加新的空文件。jsbundle名字 运行comment: react-native bundle——entry-file index.js——platform ios——dev false——bundle-output ios/main。Jsbundle——assets-dest ios 现在是react-native run-ios

youtube链接:https://www.youtube.com/watch?v=eCs2GsWNkoo

执行如下命令:

killall -9 node
rm -rf ios/build
react-native run-ios

它将打开launchpacker .command,应用程序将安装在ios模拟器上

关闭全局代理(shadowsocks)

我不得不在一个单独的终端上运行“react-native start”。由于某种原因,它不运行了

编辑:另外,这是必要的,因为文件权限设置不正确。我能够通过在受影响的项目目录中运行以下命令来修复它。

chmod 777 node_modules/react-native/scripts/ launchpacker .command

也许你忘了这一步

cd ios && pod install