我无法从创建反应应用程序创建 TypeScript 模板



我尝试通过以下命令生成一个与类型脚本集成的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****AppDataLocalnpm-cache_logs2022-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文件

创建react应用程序和react 18似乎存在持续的问题。在修复之前,请参阅此处的一些解决方法:

使用react 18 创建react应用程序依赖版本问题

相关内容

最新更新