۱ کیاوش نوری
موجود نبودن گزینه نصب react در ورژن جدید (19)
جامعه ری اکت ایجاد شده در ۰۱ بهمن ۱۴۰۳

سلام من موقع نصب این ارور رو دارم و ورژن 18 رو هم نمیتونم نصب کنم پیشنهاد یا راه حلتون چیه؟

 npx create-react-app first

Creating a new React app in D:\phpStorm-Projects\React-start\Create React\first.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


added 1323 packages in 1m

267 packages are looking for funding
 run `npm fund` for details

Initialized a git repository.

Installing template dependencies using npm...
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: first@0.1.0
npm error Found: react@19.0.0
npm error node_modules/react
npm error   react@"^19.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^18.0.0" from @testing-library/react@13.4.0
npm error node_modules/@testing-library/react
npm error   @testing-library/react@"^13.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error C:\Users\Kia\AppData\Local\npm-cache\_logs\2025-01-20T05_51_46_844Z-eresolve-report.txt
npm error A complete log of this run can be found in: C:\Users\Kia\AppData\Local\npm-cache\_logs\2025-01-20T05_51_46_844Z-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 web-vitals@^2.1.0` failed

سلام،

این ارور به خاطر ناسازگاری نسخه React 19 با کتابخونه‌های تسته.

  1. یا موقع نصب از --legacy-peer-deps استفاده کن:
    npx create-react-app first --legacy-peer-deps
  2. یا برو سراغ Vite (بهتره!):
    npm create vite@latest my-app -- --template react و نسخه 18 رو انتخاب کن.
  3. اگر میخوای حتما React 18 باشه:
    پروژه رو دستی با npm install react@18.2.0 react-dom@18.2.0 بساز.
محسن موحد ۰۴ بهمن ۱۴۰۳، ۰۶:۴۰