? ? 去年就開始接觸React Native(以下簡稱RN),嘗試著去使用朋截,隨著RN的完善万伤,現(xiàn)在國內(nèi)關(guān)于RN的技術(shù)文章越來越多省艳,關(guān)于相關(guān)的學習可以去看RN中文網(wǎng),本文只記錄下自己從剛開始使用RN遇到的一些坑散吵。
1.安裝RN之后遇到的一些問題可以通過brew update && brew upgrade解決
2.剛開始運行RN的時候報錯了,沒仔細看log,這里提醒下蓬衡,一定要仔細看log,可以解決很多的問題彤枢,這里自己就遇到了幾個常見的問題狰晚。
##Android的SDK路徑不對
###需要在環(huán)境變量配置下Android的環(huán)境變量。
##Android的最低版本是23工具是23.0.1缴啡,因為需要v7:23.0.1版本以上的包
3.出現(xiàn)
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出現(xiàn)問題,可以先刪除watchman
$brew uninstall watchman
在重新安裝
$brew install --HEAD watchman
如果報錯提示沒有安裝pcre业栅,可以安裝pcre
$brew install?pcre
如果彈出已經(jīng)安裝過秒咐,是否link,可以按照提示link下
如果一直link不上碘裕,可以使用修復
$brew -doctor
這樣就能修復了
4.出現(xiàn)
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
##解決辦法
需要安裝xcode
5.
出現(xiàn):
報這個錯誤携取,java環(huán)境變量設置不對,但檢查自己的環(huán)境變量是對的帮孔。
#指定默認版本
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)