> For the complete documentation index, see [llms.txt](https://twins-bamboo.gitbook.io/react-native-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://twins-bamboo.gitbook.io/react-native-note/start/environment-on-mac.md).

# Environment On Mac

1.根據 [RN官網](http://facebook.github.io/react-native/docs/getting-started.html) 來安裝React Native的環境

Mobile OS : IOS & Android都需要看，因為有些差異(Android Studio & Xcode都需要安裝)![](https://bambooooo.gitbooks.io/react-native/content/images/environment/1.png)![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/environment/1.png)

\
2.安裝完react native後 .bashrc的設定

開啟terminal

> $ cd \~
>
> $ ls -a (此時可看見.bashrc等檔案)
>
> $vi .bashrc

按一下鍵盤上的「i」開始編輯，請看到左下角有「INSERT」之後再開始輸入。![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/environment/2.png)

編輯完之後，先按一下鍵盤左上角的「esc」然後輸入「:wq」儲存並關閉，如果只想要儲存不要關閉畫面，輸入「:w」就可以了，再次編輯檔案一樣要再按一下「i」。![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/environment/3.png)

\
3.看該目錄下有無 .bash\_profile 若沒有則新增

在該檔案內輸

`if [ -f ~/.bashrc ]; then . ~/.bashrc; fi`

![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/environment/4.png)

確定.bashrc 和 .bash\_profile 兩個檔案都有

![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/environment/5.png)

\
4.確認變量都有寫入

> $ source .bash\_profile
>
> $ export

如下圖，內有ANDROID\_HOME等剛剛設定的變量

![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/environment/6.png)

\
查看rn版本 (terminal路徑在rn project下)

`$ react-native -v`

![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/environment/7.png)![](https://bambooooo.gitbooks.io/react-native/content/React%20Native%20Learn/images/environment/6.png)

參考

<http://superuser.com/questions/147043/where-to-find-the-bashrc-file-on-mac-os-x-snow-leopard-and-lion>

<http://elf8848.iteye.com/blog/1582137>
