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


当前回答

确保launchPackage.command在终端中运行,然后重试运行。它将构建捆绑包。它有点像webpack-dev-server。

其他回答

在info.plist中的NSExceptionDomains字典中检查你的“localhost”键

如果它不存在,就会导致错误。

对于我的用例,我必须删除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

首先关闭模拟器,然后在终端上运行这些程序

npm install

react-native run-ios

检查你的网络代理,最好关闭它。

或者你应该找其他方法来维护打包服务器

是什么帮我解决了这个问题:

打开终端窗口 cd到YOUR_PROJECT/ios 使用rm -r build删除build文件夹 再次运行react-native Run -ios

或者,你可以打开Finder,导航到YOUR_PROJECT/ios并删除构建文件夹。

然后再次运行react-native run-ios。

资料来源:Andrew Bancroft