React Native 初次安裝踩坑
這次終於燃起了學習react的動力,在初步了解後開始進入react native的學習,更早之前其實有玩過expo,不過使用expo也會有些無法使用原生套件的問題,既然要先學習就從扎實的開始吧!
安裝react native
首先一開始我先安裝了全局
react-native init yourProjectName
後來在跑的時候卻報錯了
typeError: cli.init is not a function
搜索了下解決方法是删除全局的react-native-cli
npm uninstall -g react-native-cli
隨後再次run了建立的指令,不意外的又報錯了....
bundle install
Your Ruby version is 2.6.6, but your Gemfile specified 2.7.5
於是繼續google,解決方案則是: 將Gemfile裡的版本改成設置提示版本
#You can try these commands to install and change global Ruby version to 2.7.5
brew update
brew install ruby-build
brew install rbenv
# If you're using rvm:
rvm install 2.2.5
rvm use 2.2.5
# else if you're using rbenv:
rbenv install 2.7.5
rbenv global 2.7.5
#After that, you need to export some configurations to define rbenv as default global ruby:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
其餘遇見的錯誤:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
解決:
直接去Apple 官網下載最新版本的Command Line Tools安裝即可,然後再通過brew config查看當前CLI版本號是否變更 鏈接:https://developer.apple.com/download/more/