0

Problems With React Project - React JS

Hello Everyone, I've been trying for a while now to begin working on an existing React project. First of all, I dowloaded the latest version of Node JS and then cloned the repo from GitHub. I did my way to the directory where I can find "package.json" and did "npm i". AT THAT MOMENT, I got many errors such as: "npm WARN ERESOLVE overriding peer dependency" and "npm WARN Conflicting peer dependency: react@17.0.2" After that, I did the following (was advised by people on StackOverFlow): npm install --legacy-peer-deps npm audit fix --force When it finished it still said that there are more issues needed to be fixed for some reason. Even though I knew there were more problems, I did "npm start" to see the website. A page on localhost:3000 opened - good news, but then it told me: " 'React' must be in scope when using JSX react/react-in-jsx-scope ". I got that error on many files, after some researching I understood that dozens of files are missing the simple react import (import React from 'react'). I added every import, but then it said that some files inside the node_modules have syntax error such as missing brackets. I don't know what to do anymore, I need your help - I explained everything as detailed as I can. Worth mentioning, I reinstalled Node JS and re-cloned the repo multiple times. In addition, the project runs perfectly on my friends computer. Bless all helpers.

26th Aug 2022, 12:06 PM
Yahel
Yahel - avatar
3 odpowiedzi
+ 1
Welcome to dependency hell! Hope you're having a great time. If you want, you can upload your package.json and the exact error messages (conflicting peer deps) to hastebin and I can take a look. One thing you can try: If, in your package.json, you see that version numbers are starting with a caret ("^"), then remove all the carets and run npm install again. conflicting peer deps are annoying, basically it means a package requires a slightly different version of another package than what you have installed. In theory it should be fixable by changing some version numbers in your package.json.
26th Aug 2022, 2:38 PM
Schindlabua
Schindlabua - avatar
0
Yahel Sorry for bad formatting I'm on a phone :) https://hastebin.com/wepirevofe.json Replace your package.json with this (delete package-lock maybe) and run npm install. See if it does anything for you. Changes: I strictly set all the versions (removed the ^), and downgraded `react` and `react-dom` to version 17.0.0 (was 18.0.0). The project installs correctly for me now, at least on my phone (node v16.16.0) Don't hesitate to post if you run into problems.
29th Aug 2022, 12:24 AM
Schindlabua
Schindlabua - avatar