5

Hi guys I have a problem with NPM dependencies.

It turns out that in my project, I'm using React version 17.0.2 but I have several libraries that depend on React 16.3.2 and I really don't know what to do.

Is there any way for me to have multiple versions of React at once? So that each the various libraries dock different versions of react?

Another thing that makes me curious is that the project runs fine here locally, but in production, with npm run build, everything breaks, which makes compilation impossible.

Error thrown by the console

I have already tried deleting the node_modules folder and my package-lock.json file to then install again npm install --force and npm install --legacy-peer-deps and as I told you, it works locally but in production everything breaks.

Here I attach my package.json file

https://gist.github.com/luisyuburi/6c5517b31cccef00f45fc8e12329f1f1

Luisyubu23
  • 61
  • 3
  • check this link https://stackoverflow.com/a/66035709/66384 If you have NPM v7 you will generally get this error. – tHeSiD Mar 25 '21 at 14:23
  • As I said before, here locally I use npm install --force or npm install --legacy-peer-deps and everything is fine. The errors jump to me when in the virtual machine, I take to production the command npm run build, that's where everything breaks. – Luisyubu23 Mar 25 '21 at 15:40
  • Side note: I couldn't find the package: `"boostrap": "^2.0.0"` on https://www.npmjs.com/search?q=boostrap – Janez Kuhar Mar 25 '21 at 17:32
  • 1
    According to your `package.json`, you're *not* using React version `17.0.2`, but `^16.3.2`. That is, you have to update both packages: `react` and `react-dom`. – Janez Kuhar Mar 25 '21 at 17:36
  • While in your case it is actually clearer to post your code sample as a gist and the error as an image, this is generally discouraged on StackOverflow. Try to keep that in mind in your future questions on the site. – Janez Kuhar Mar 25 '21 at 18:03
  • Was this ever resolved? I'm encountering the same problem right now. – Bashiru Ismail Babatunde Apr 22 '22 at 23:28

0 Answers0