create-react-app之入门

1.入门

create-react-app是创建单页React应用程序的官方支持方式。它提供了无需配置的现代化构建设置。

1.1 快速入门

npx create-react-app my-app
cd my-app
npm run start

然后打开http://localhost:3000,查看应用

当您准备部署到生产环境时,请使用创建最小化的捆绑包npm run build

如果您以前create-react-app通过进行了全局安装npm install -g create-react-app,建议您使用npm uninstall -g create-react-app或yarn global remove create-react-app卸载软件包,以确保npx始终使用最新版本。

1.2 创建应用程序

您需要在本地开发计算机上使Node> = 10(但在服务器上不是必需的)。您可以使用nvm(macOS / Linux)或nvm-windows在不同项目之间切换Node版本。

要创建新应用,您可以选择以下方法之一:

npx:

npx create-react-app my-app

npm:

npm init react-app my-app

npm ini

猜你喜欢

转载自blog.csdn.net/qq_27868061/article/details/112341680