React 项目安装流程

本文介绍了如何使用create-react-app快速创建React项目,包括全局安装与npx使用方式,详细解析了项目创建过程中的组件,如react、react-dom和react-scripts。在遇到npm安装问题时,提供了切换npm镜像、使用yarn以及降低react-scripts版本等解决方案。
摘要由CSDN通过智能技术生成

create-react-app

全局安装create-react-app

$ npm install -g create-react-app

如果不想全局安装,可以直接使用npx

$ npx create-react-app your-app 也可以实现相同的效果

创建一个项目

$ create-react-app your-app 注意命名方式
Creating a new React app in /dir/your-app.
Installing packages. This might take a couple of minutes. 安装过程较慢,可以推荐使用yarn
Installing react, react-dom, and react-scripts...

这需要等待一段时间,这个过程实际上会安装三个东西

  • react: react的顶级库
  • react-dom: 因为react有很多的运行环境,比如app端的react-native, 我们要在web上运行就使用react-dom
  • react-scripts: 包含运行和打包react应用程序的所有脚本及配置
    出现下面的界面,表示创建项目成功:
Success! Created your-app at /dir/your-app
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值