create-react-app需要升级版本
- 卸载旧版本
yarn global remove create-react-app
- 安装新版本
yarn global add create-react-app
提示某些包装不上
提示信息如下:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @typescript-eslint/scope-manager@5.20.0.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/windf/.npm/_logs/2022-04-25T11_42_34_885Z-debug-0.log
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template-typescript has failed.
Deleting generated file... package.json
Deleting cookbooks/ from /home/windf
Done.
调整使用国内源并清缓存
- npm源
npm config set registry https://repo.huaweicloud.com/repository/npm/
npm cache clean -f
- yarn源
yarn config set registry https://repo.huaweicloud.com/repository/npm/
创建项目
- 创建javaScript项目
create-react-app 项目名称
- 创建typeScript项目
create-react-app --template typescript 项目名称
最后推荐三个开源镜像站
华为:https://mirrors.huaweicloud.com/home
阿里:https://developer.aliyun.com/mirror/
腾讯:https://mirrors.cloud.tencent.com/