React Native报错问题记录(多种解决方案,持续更新)

1, 问题: react-native run-ios报错,Error watching file for changes: EMFILE

Snip20180713_3.png
  • 解决:
 brew uninstall watchman
// 报错a 

brew uninstall --force watchman
brew cleanup --force -s watchman
brew prune
brew install watchman

// 报错b  Error: An unexpected error occurred during the `brew link` step The formula built, but is not symlinked into /usr/local Permission denied @ dir_s_mkdir - /usr/local/Frameworks Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

sudo mkdir /usr/local/Frameworks
sudo chown $(whoami):admin /usr/local/Frameworks

brew install watchman
react-native run-ios

2,问题:No bundle URL present

Simulator Screen Shot - iPhone X - 2018-07-13 at 11.06.30.png
  • 解决:

  • 方法---1,(现在不管用)

Run "react-native run-ios"
When the error appears, run "npm install"
Then run "react-native run-ios" again.
check your hosts that 127.0.0.1    localhost is not delete
check that the network agent is not set up
then'npm install & react-native upgrade' to reset your project

3, The engine "node" is incompatible with this module (或Command yarn add react-native --exact failed.)

error react-native@0.56.0: The engine "node" is incompatible with this module
....
stderr: null,
stdout: null,
pid: 7395,
output: [ null, null, null ],
signal: null,
status: 1 }
Command yarn add react-native --exact failed.
  • 解决:
    更新node
### 第一步:使用npm安装n模块

* * *

n模块是专门用来管理nodejs版本的

sudo npm install -g n

> **提示 :** 如果不使用sudo作为前缀,很可能出现权限访问异常导致安装失败

### 第二步:升级nodejs

* * *

升级nodejs是有两种方法: 
第一种是升级到最新版本

sudo n latest

第二种是升级到稳定版本

sudo n stable

> **提示 :** 建议是稳定版本 
> 更多n模块管理请搜索【nodejs n模块使用说明】

4, TypeError [ERR_INVALID_CALLBACK]: Callback must be a function

$ pushy uploadIpa <your-package.ipa> 

当我使用目前最新的 node 版本(10.x.x)时会报错

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at maybeCallback (fs.js:124:9)
    at Object.fs.write (fs.js:642:14)
    at /Users/www/admin/build/webpack.dev.config.js:12:8
    at FSReqWrap.oncomplete (fs.js:136:20)
  • 解决:
类似于这样的错误,这是因为 node 版本太高了,我们需要降级,亲测降到 v8.11.1 可行,不过我发现此 bug 在前两天已经被 react-native-update 的维护者修复了,如果依然碰到这个问题,可以试试此方法。

5, 问题: pushy uploadIpa xxx.ipa,Error: Validation error

6, 问题: npm install,Error: Cannot find module 'semver'

Snip20180802_16.png
  • 解决:
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --ignore-dependencies node
brew install node

7,问题:'config.h' file not found

  • 解决:
$ rm -rf node_modules/ && yarn cache clean && yarn install
$ ls node_modules/react-native/ (missing third-party directory)

$ node_modules/react-native/ios-install-third-party.sh or node_modules/react-native/scripts/ios-install-third-party.sh
$ ls node_modules/react-native/ (third-party directory found)
  • 参考:


    Snip20180803_23.png

https://github.com/facebook/react-native/issues/14382

8, 集成react native到xcode,pod install 报错

~/Desktop/HuanXiangJiHua$ pod install
Analyzing dependencies
Fetching podspec for `CodePush` from `./ReactComponent/node_modules/react-native-code-push`
Fetching podspec for `DoubleConversion` from `./ReactComponent/node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `./ReactComponent/node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `React` from `./ReactComponent/node_modules/react-native`
Fetching podspec for `glog` from `./ReactComponent/node_modules/react-native/third-party-podspecs/glog.podspec`
Fetching podspec for `yoga` from `./ReactComponent/node_modules/react-native/ReactCommon/yoga`
[!] CocoaPods could not find compatible versions for pod "Folly":
  In Podfile:
    Folly (from `./ReactComponent/node_modules/react-native/third-party-podspecs/Folly.podspec`)

Specs satisfying the `Folly (from `./ReactComponent/node_modules/react-native/third-party-podspecs/Folly.podspec`)` dependency were found, but they required a higher minimum deployment target.
[!] Automatically assigning platform `ios` with version `8.0` on target `Unity-iPhone` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
  • 解决:
    问题就在上面最后一句警告。
    xcode项目使用的9.0和Folly的最低支持版本(9.0)不符.
    需将xcode版本改为最低支持9.0

tips:
查看Folly的最低支持版本——用文本编辑器打开./ReactComponent/node_modules/react-native/third-party-podspecs/Folly.podspe能看到其最低支持的版本

9, Failed to connect to 127.0.0.1 port 1080: Connection refused

pod install (或 pod update)

  • 报错信息
[!] Error installing Crashlytics
[!] /usr/bin/curl -f -L -o /var/folders/kz/p8_vcv1x0mn6x0wfmwy7z9d00000gn/T/d20180426-13131-1jlkxa7/file.zip https://kit-downloads.fabric.io/cocoapods/crashlytics/3.10.0/crashlytics.zip --create-dirs --netrc-optional

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to 127.0.0.1 port 1080: Connection refused

cocopods 导入库 的时候时常被这个个错误困扰,

  • 思路一:
    网上的解决办法千篇一律,就是移除代理
    不过对我没用。还是给出这个方案,也许对你有效
查询是否使用代理:git config --global http.proxy 
取消代理:git config --global --unset http.proxy
  • 思路二:
    下面给出对我有效的方案

找到自己本机账号下面的.curlrc文件,把它里面的 socks5 = "127.0.0.1:1080"insecure干掉

(注: 显示隐藏文件(终端输入 defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder)可以在finder本机账户看到隐藏文件 .curlrc)

ps:暂未出现副作用,详细原因后续查明更新
感谢:# Error installing Crashlytics - SSL peer handshake failed [closed]

10, 'React/RCTBridgeModule.h' file not found

  • 解决:


    Snip20180921_4.png

11,"OBJC_CLASS$_ RCTBridge", referenced from: objc-class-ref in MT AppController.o

Snip20180921_6.png

思路:pod install报的警告着手

[!] The `Unity-iPhone [Release]` target overrides the `OTHER_CFLAGS` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `Unity-iPhone [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `Unity-iPhone [Debug]` target overrides the `OTHER_CFLAGS` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `Unity-iPhone [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

解决:


Snip20180925_1.png

12, The file “xxx” couldn’t be opened because you don’t have permission to view it

13, npm install 白色进度条卡住不动,安装卡住

解决:
1,❗️网上好多都是换镜像(对我这次不行,那就不是镜像的问题);
2,✅删除package-lock.json,node-modules,再执行npm install,问题解决(对我有效);

延伸:
为什么删除package-lock.json生效?


Snip20181022_13.png

14,react-native run-ios 运行报错:Print: Entry, ":CFBundleIdentifier", Does Not Exist

在项目文件夹下执行:
第一步
cd node_modules/react-native/scripts && ./ios-install-third-party.sh && cd ../../../
第二步
cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh && cd ../../../../
⚠️注意:第二步命令“golg-0.3.5”需要改成你的glog版本
可以在以下文件夹查看你的golg ( YourReactNativeProject ▸ ⁨node_modules⁩ ▸ ⁨react-native⁩ ▸ ⁨third-party⁩)
第三步重启服务:
npm start
参考: https://blog.csdn.net/chensenp/article/details/83543724

15,

Build input file cannot be found: 'xxx/double-conversion-1.1.5/src/strtod.cc'
  • 解决:
    cd node_modules/react-native/scripts && ./ios-install-third-party.sh && cd ../../../
    cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh

16,Error: fsevents unavailable (this watcher can only be used on Darwin)

  • 解决:
sudo chown -R whoami /usr/local
brew install watchman

17,Modal was presented with 0x0 orientations mask but the application only supports 0x18.Add more interface orientations to your app's Info.plist to fix this.NOTE: This will crash in non-dev mode.

文末提醒

其实react-native相关问题多看看
https://github.com/reactnativecn/react-native-pushy/issues
还是能有效解决,网上搜还是比较浪费时间

18,error: no type named 'NamedPropertyGetterCallback' in namespace 'v8'; did you mean 'IndexPropertyGetterCallback'?

  • 解决:

最近安装realm的时候一直报这个错,Google发现需要降级node到9.8.0

brew install npm
npm install -g node@9.8.0
brew install yarn

然后再执行
npm install --save realm 就可以成功了

19,undefined is not a function (near '...a.Sync._initializeSyncManager...') 或者 realmConstructor.Sync._initializeSyncManager is not a function

  • 解决:
    node_modules/realm/lib/index.js里面 realmConstructor.Sync._initializeSyncManager(createUserAgentDescription());注释掉
    然后打main.jsbundle,发布到code-push

realm用着有点蛋疼,打算后期换掉

参考:https://github.com/realm/realm-js/issues/2128

20, runtime is not ready for debugging

8bc6611e-893b-4449-b72f-4f0ed8fe9acc.jpg
  • 解决:
    在RCTWebSocketExecutor.m文件中,把localhost修改为与加载RN页面http://xxx.xxx.xx.xx:8081/index.bundle?platform=ios中相同的IP地址(一般为电脑IP).

  • 参考:
    https://www.jianshu.com/p/90ceb04da552

21,init 命令默认会创建最新的版本,而目前最新的 0.45 及以上版本需要下载 boost 等几个第三方库编译。这些库在国内即便翻墙也很难下载成功,导致很多人无法运行iOS项目!!!`

  • 解决:
    中文网在论坛中提供了这些库的国内下载链接。如果你嫌麻烦,又没有对新版本的需求,那么可以暂时创建0.44.3的版本。

提示:你可以使用--version参数(注意是个杠)创建指定版本的项目。例如react-native init MyApp --version 0.44.3。注意版本号必须精确到两个小数点。

23,failed to load bundle(http://127.0.0.1 xxxxxx) xxx could not connect to developer server

  • 解决:
    看iOS xcode中的日志得知是未允许http导致,xcode中配置一下ATS就好了。
    当然你不一定是这个问题
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 148,637评论 1 318
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 63,443评论 1 266
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 99,164评论 0 218
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 42,075评论 0 188
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 50,080评论 1 266
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 39,365评论 1 184
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 30,901评论 2 283
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 29,649评论 0 176
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 33,122评论 0 223
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 29,734评论 2 225
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,093评论 1 236
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 27,548评论 2 222
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,028评论 3 216
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 25,765评论 0 9
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,291评论 0 178
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 34,162评论 2 239
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 34,293评论 2 242

推荐阅读更多精彩内容