创建一个项目非常的简单,直接去看官网就可以了。链接:创建一个新的 React APP - React 中文网
我参考的教程上需要使用react + typescript,所以直接在创建的时候,命令行加上了typescript的template。
命令行:
npx create-react-app client-app --use-npm --template typescript
安装完成后可以看到:
Success! Created client-app at /Users/miemie/Desktop/Reactivies/client-app
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd client-app
npm start
几个菜坑点:
菜坑1: 注意node js 和 npm的版本
不需要最新,但是至少要支持: Node >= 6 和 npm >= 5.2
菜坑2: 使用的mac os之前没有更新过tar,所以在第一次的时候会报错:
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
只需要更新一下:
npm install -g tar