一、简介
这是一篇使用create-react-app 的简单入门
- create-react-app
Create React App is the best way to starting building a new React single page application
二、入门
- 运行npm install -g create-react-app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22$ npm install -g create-react-app
D:\git\nvmw\v6.3.0\create-react-app -> D:\git\nvmw\v6.3.0\node_modules\create-react-app\index.js
D:\git\nvmw\v6.3.0
`-- create-react-app@0.6.0
+-- chalk@1.1.3
| +-- ansi-styles@2.2.1
| +-- escape-string-regexp@1.0.5
| +-- has-ansi@2.0.0
| | `-- ansi-regex@2.0.0
| +-- strip-ansi@3.0.1
| `-- supports-color@2.0.0
+-- cross-spawn@4.0.2
| +-- lru-cache@4.0.1
| | +-- pseudomap@1.0.2
| | `-- yallist@2.0.0
| `-- which@1.2.11
| `-- isexe@1.1.2
+-- minimist@1.2.0
+-- path-exists@2.1.0
| `-- pinkie-promise@2.0.1
| `-- pinkie@2.0.4
`-- semver@5.3.0 - 使用create-react-app my-app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23$ npm install -g create-react-app
D:\git\nvmw\v6.3.0\create-react-app -> D:\git\nvmw\v6.3.0\node_modules\create-react-app\index.js
D:\git\nvmw\v6.3.0
`-- create-react-app@0.6.0
+-- chalk@1.1.3
| +-- ansi-styles@2.2.1
| +-- escape-string-regexp@1.0.5
...
Success! Created my-app at D:\nodejs\my-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 my-app
npm start
Happy hacking! - 进入应用并启动
1
2
3
4
5
6
7
8
9$ cd my-app
$ npm start
Starting the development server...
Compiled successfully!
The app is running at:
http://localhost:3000/
Note that the development build is not optimized.
To create a production build, use npm run build.