前置

已经配置好了所需环境。我们找一个项目目录,例:D:\work\VSCODE

验证工作环境

image.png

create-react-app 做了什么?

如果我们已经创建过React App项目,我们会发现在 …\npm\create-react-app目录下已经有了create-react-app全局模块,我们不妨先卸载掉它。

卸载create-react-app全局模块

npm uninstall -g create-react-app
image.png
在无create-react-app全局模块的情况下,是否可搭建React App?
image.png

安装create-react-app全局模块

npm install -g create-react-app
我们发现在我们的 …\npm\create-react-app目录下有了create-react-app全局模块
此时,我们便可以使用它来搭建一个React App项目。
image.png

说明

Create React App 是一个官方支持的创建 React 单页应用程序的方法。它提供了一个零配置的现代构建设置。也称为react脚手架。

搭建一个React App项目

搭建一个名为my-react的React APP项目
create-react-app my-react
image.png
伸个懒腰~
image.png
image.png
根据提示,我们已经知道了React App项目已经搭建完成了。

运行React App

cd my-react
npm start
image.png
此时,打开http://localhost:3000/在浏览器就运行了一个React App项目了。
~
~

别的不管!你现在已经是一个合格的React开发者了!!!
image.png