- 安裝 Node.js
- 安裝git
- 打開Node.js Command
-
打上 npx create-react-app your-app-name
- 輸入 cd your-app-name
- 打開 ./you-app-name 資料夾裡的 package.json 檔
- 在裡面加入
“homepage”: “http://youraccout.github.io/your-app-name“
….scripts”: {
“predeploy”: “npm run build”,
“deploy”: “gh-pages -d build”
}
如下圖
- 在裡面加入
![](https://i0.wp.com/mrcodingroom.freesite.host/wp-content/uploads/2019/10/image.png?resize=409%2C673&ssl=1)
6. 去github網站,創建你的repository 名字要和你的your-app-name相同
7. 複製你的repository的 git 如下圖 找不到也可以用打的 https://github.com/youraccount/your-app-name.git
![](https://i1.wp.com/mrcodingroom.freesite.host/wp-content/uploads/2019/10/image-1.png?fit=640%2C476&ssl=1)
![](https://i2.wp.com/mrcodingroom.freesite.host/wp-content/uploads/2019/10/image-2.png?fit=640%2C291&ssl=1)
8. 在command line上打
git init
git remote add origin https://github.com/youraccount/your-app-name.git
(此時需要輸入github帳密)
git add .
git commit -m “Your awesome message”
git push origin master
npm run deploy
9. 完成後 http://youraccout.github.io/your-app-name
看你的第一個在github上React程式吧
@copyright MRcodingRoom
觀看更多文章請點MRcoding筆記
觀看更多文章請點MRcoding筆記