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


当前回答

这是因为您的客户机无法连接到您的打包器服务器。

如果你是一个像我一样的中国程序员,我认为你可能会使用VPN通过GFW。当您的VPN工具处于“全局模式”时,您的所有请求都将通过世界旅行,无法到达本地主机

试试“自动代理模式”。

如果你不是来自中国,或者你的VPN设置已经是“自动代理模式”,我建议你关闭你的打包服务器,再试一次。

其他回答

对于我的用例,我必须删除node_modules目录并运行npm install。

$ rm -rf node_modules   (make sure you're in the ios project directory)
$ npm install

如果你得到错误“dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58。Dylib”,执行以下操作:

$ brew uninstall --force node --ignore-dependencies node
$ brew uninstall icu4c --ignore-dependencies icu4c
$ brew install icu4c
$ brew unlink icu4c && brew link icu4c --force
$ brew install node

$ npm install

也许你忘了这一步

cd ios && pod install

执行如下命令:

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

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

我在我的macbook上通过电缆和wifi连接到网络,关闭wifi,点击运行,它就工作了!

步骤1: 在xcode中打开。xcodeworkspace项目,通过“Terminal”导航, “开放/ ios /。xcodeworkspace"按Enter键。

步骤2: 删除主机。Jsbundle文件

步骤3: 回到VS Code,输入这个, React-native bundle——entry-file index.js——platform ios——dev false——bundle-output ios/main。Jsbundle——assets-dest ios

这将生成新的主线。jsbundle文件。

步骤4: react-native run-ios

你不会再次看到错误