1. 程式人生 > >一、create-react-app的安裝及使用

一、create-react-app的安裝及使用

一、安裝create-react-app

1、在全域性環境中安裝create-react-app

npm install -g create-react-app

2、在您所需要的目錄(盤)下生成一個專案 【前提是第一步安裝成功】

create-react-app my-app

二、開發環境執行專案及編譯後釋出到線上環境

1、進入my-app的根目錄

cd my-app/

2、執行下面的命令即可在本地開發環境中執行專案

npm start

3、如需要釋出到線上環境則執行下面的命令進行編譯得到build檔案,然後將build檔案釋出到線上伺服器

npm run build

4、如要在本地檢視線上環境的效果可以執行下面的命令

npm install -g pushstate-server
pushstate-server build

 

參考:https://blog.csdn.net/qtfying/article/details/78665664