我无法从 create-react-app 创建 TypeScript 模板

I can't create TypeScript template from create-react-app

我尝试通过以下命令生成与类型脚本集成的 React 应用程序。

npx create-react-app my-app --template typescript

我在终端中收到以下错误

Installing template dependencies using npm...
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app@0.1.0
npm ERR! Found: react@18.0.0
npm ERR! node_modules/react
npm ERR!   react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"<18.0.0" from @testing-library/react@12.1.5
npm ERR! node_modules/@testing-library/react
npm ERR!   @testing-library/react@"^12.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\


npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\****\AppData\Local\npm-cache\_logs22-04-    12T11_50_29_275Z-debug.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^12.0.0 @testing-library/user-event@^13.2.1 @types/jest@^27.0.1 @types/node@^16.7.13 @types/react@^17.0.20 @types/react-dom@^17.0.9 typescript@^4.4.2 web-vitals@^2.1.0` failed

从这个命令生成的应用程序无法正常工作,它有很多反应功能,比如在我的 .tsx

中导入 .css 文件

create-react-app 和 React 18 似乎一直存在问题。在问题解决之前,请在此处查看一些解决方法: