React Native自己遇到的一些坑总结(MAC)

2016-04-18  本文已影响0人  KimXu

    去年就开始接触React Native(以下简称RN),尝试着去使用,随着RN的完善,现在国内关于RN的技术文章越来越多,关于相关的学习可以去看RN中文网,本文只记录下自己从刚开始使用RN遇到的一些坑。


1.安装RN之后遇到的一些问题可以通过brew update && brew upgrade解决


2.刚开始运行RN的时候报错了,没仔细看log,这里提醒下,一定要仔细看log,可以解决很多的问题,这里自己就遇到了几个常见的问题。

##Android的SDK路径不对

###需要在环境变量配置下Android的环境变量。

##Android的最低版本是23工具是23.0.1,因为需要v7:23.0.1版本以上的包


3.出现

dyld: Library not loaded:/usr/local/lib/libpcre.1.dylib Referenced from:/usr/local/bin/watchman Reason: image not found dyld: Library not loaded:/usr/local/lib/libpcre.1.dylib Referenced from:/usr/local/bin/watchman Reason: image not found Watchman: watchman--no-pretty get-sockname returnedwithexit codenulldyld: Library not loaded:/usr/local/lib/libpcre.1.dylib Referenced from:/usr/local/bin/watchman Reason: image not found ERROR watchman--no-pretty get-sockname returnedwithexit codenulldyld: Library not loaded:/usr/local/lib/libpcre.1.dylib Referenced from:/usr/local/bin/watchman Reason: image not found Error: watchman--no-pretty get-sockname returnedwithexit codenulldyld: Library not loaded:/usr/local/lib/libpcre.1.dylib Referenced from:/usr/local/bin/watchman Reason: image not found at ChildProcess.(/Users/Jing/Projects/ReactNative/AwesomeProject/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/index.js:194:18)at emitTwo (events.js:87:13) at ChildProcess.emit (events.js:172:7) at maybeClose (internal/child_process.js:817:16) at Socket.(internal/child_process.js:319:11) at emitOne (events.js:77:13) at Socket.emit (events.js:169:7) at Pipe._onclose (net.js:469:12)

##通过如下命令即可修复:

$brew uninstall pcre && brew install pure

如果还不好使,应该是watchman出现问题,可以先删除watchman

$brew uninstall watchman

在重新安装

$brew install --HEAD watchman

如果报错提示没有安装pcre,可以安装pcre

$brew install pcre

如果弹出已经安装过,是否link,可以按照提示link下

如果一直link不上,可以使用修复

$brew -doctor

这样就能修复了


4.出现

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

##解决办法

需要安装xcode


5.

出现:

报这个错误,java环境变量设置不对,但检查自己的环境变量是对的。

#指定默认版本

exportJAVA_HOME=`/usr/libexec/java_home`

exportJAVA_HOME=$(/usr/libexec/java_home)

#指定自定义版本

exportJAVA_HOME=`/usr/libexec/java_home-d64-v1.6`

exportJAVA_HOME=$(/usr/libexec/java_home-d64-v1.6)


上一篇下一篇

猜你喜欢

热点阅读