Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple versions of react (react-dom uses old react dependency)

I was getting the famous two versions loaded error. I ran the line npm ls | grep reactand got the following:

├─┬ [email protected]
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
├── [email protected]
│ ├─┬ [email protected]
│ └── [email protected]

It seems that react-dom uses [email protected] while the rest of my project uses [email protected].

What do I do to make react-dom not load this older version of react? I thought that this was the most up-to-date version of react-dom.

Note: I am using npm version 2.15.1 and node version v4.4.4

like image 986
ApathyBear Avatar asked May 24 '16 14:05

ApathyBear


People also ask

Do React and React-Dom need to be the same version?

Yes, it should be the same version.

Is React-Dom a dependency?

dependencies are packages used in your app's production bundle. If you're building a React app, then react and react-dom would be dependencies .

How do you solve You might have more than one copy of React in the same app?

4 answers. In the module you are developing, add the conflicting packages to peerDependencies (and remove them from dependencies or devDependencies ): // package. json "peerDependencies": { "react": "16.13.

What is difference between React and React-Dom?

What is the difference? The react package holds the react source for components, state, props and all the code that is react. The react-dom package as the name implies is the glue between React and the DOM. Often, you will only use it for one single thing: mounting your application to the index.


1 Answers

You can try https://docs.npmjs.com/cli/dedupe, if Nicole's comment, with clean reinstall, does not help.

like image 142
aocenas Avatar answered Nov 04 '22 09:11

aocenas