1、首先安装react脚手架
npm install -g create-react-app
1
2、创建react项目
create-react-app my-app
1
3、
PS D:\桌面\papers\subject> create-react-app my-react-app
Creating a new React app in D:\桌面\papers\subject\my-react-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1479 packages in 27s
252 packages are looking for funding
run npm fund
for details
Initialized a git repository.
Installing template dependencies using npm...
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@testing-library/dom@10.4.0',
npm WARN EBADENGINE required: { node: '>=18' },
npm WARN EBADENGINE current: { node: 'v16.17.0', npm: '8.15.0' }
npm WARN EBADENGINE }
added 63 packages, and changed 1 package in 6s
252 packages are looking for funding
run npm fund
for details
Removing template package using npm...
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@testing-library/dom@10.4.0',
npm WARN EBADENGINE required: { node: '>=18' },
npm WARN EBADENGINE current: { node: 'v16.17.0', npm: '8.15.0' }
npm WARN EBADENGINE }
removed 1 package in 1s
252 packages are looking for funding
run npm fund
for details
Created git commit.
Success! Created my-react-app at D:\桌面\papers\subject\my-react-app
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
npm test
Starts the test runner.
npm run eject
Compiled successfully!```
3、根据提示进入项目目录
```javascript
cd my-react-app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
4、启动项目
npm run start
1
5、浏览器中出现react图标项目就创建成功并运行了