$ cnpm install -g create-react-app //創建react全局變量 $ create-react-app my-app //創建一個react項目
國內使用 npm 速度很慢,如果報以上錯誤等,可以使用淘寶定制的 cnpm (gzip 壓縮支持) 命令行工具代替默認的 npm:
$ npm install -g cnpm --registry=https://registry.npm.taobao.org //此行代碼是用來將npm替換成cnpm(淘寶鏡像)使得安裝速度變快 $ npm config set registry https://registry.npm.taobao.org //此行代碼是解決cnpm安裝的時候,也會去請求registry.npmjs.ord網站出現的速度變慢,或者報錯的問題
-- 配置后可通過下面方式來驗證是否成功 $ npm config get registry 或 npm info express
創建完成后,然后進行下一步操作
$ cd my-app/ $ npm start