react 19
来源:2-5 【TypeScript配置】tsconfig.json详解

qq_慕桂英6324852
2024-12-18
新出的react 19
PS E:\react> npx create-react-app app-ts --template typescript
Creating a new React app in E:\react\app-ts.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template-typescript...
added 1320 packages in 29s
256 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: app-ts@0.1.0
npm ERR! Found: react@19.0.0
npm ERR! node_modules/react
npm ERR! react@"^19.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@13.4.0
npm ERR! node_modules/@testing-library/react
npm ERR! @testing-library/react@"^13.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\10100\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\10100\AppData\Local\npm-cache\_logs\2024-12-17T23_25_46_423Z-debug-0.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^13.0.0 @testing-library/user-event@^13.2.1 @types/jest@^27.0.1 @types/node@^16.7.13 @types/react@^18.0.0 @types/react-dom@^18.0.0 typescript@^4.4.2 web-vitals@^2.1.0` failed
说实话看不懂,我知道那里冲突了 但是我不知道咋解决
不用ts就可以使用 但是还是得下一个 web-vitals
老师帮我解决一下 感谢
写回答
3回答
-
阿莱克斯刘
2024-12-22
creat react app 总是安装最新版本的react,所以创建react18需要做一些额外的配置:
1. 确保你已安装了 Node.js 和 npm。你可以在中运行 `node -v` 和 `npm -v` 来检查。
2. 打开终端,运行以下命令来全局安装 Create React App:
npx create-react-app my-react-app
3. 进入项目目录:
cd my-react-app
4. 安装 React 18:
npm install react@18 react-dom@18
5. 启动开发服务器:
npm start
这样,你就可以在浏览器中访问 `http://localhost:3000` 来查看你的 React 18 项目了。希望这能帮到你!如果还有其他问题,尽管告诉我。00 -
qq_慕桂英6324852
提问者
2024-12-21
typescript 不能安装高的版本 老是报一些错误 冲突什么的 目前还没有解决办法 create-react-app
00 -
qq_慕桂英6324852
提问者
2024-12-18
目前搞得能运行了
npm install @testing-library/jest-dom @testing-library/react @testing-library/user-event @types/jest @types/node @types/react @types/react-dom typescript web-vitals
把这些重新下了一遍,一开始有冲突全都没下上,下的默认版本好像太低了 还有web-vitals 还是不行我就把文件删掉了,好像是测试文件,目前是能运行了
00
相似问题