[DOCKER] ERESOLVE unable to resolve dependency tree

background

In Docker's node container, create a React project with create-react-app and It was an error that occurred when I subsequently tried to install material-ui.

Conclusion

If you want to ** install that library **, add ** --save --legacy-peer-deps ** after npm install. Alternatively, consider ** downgrading ** the project you are installing from. ..

Background

# material-When I try to install ui. ..
npm install @material-ui/core
#Such an error occurs. ..
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   [email protected]"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer [email protected]"^16.8.0" from @material-ui/[email protected]
npm ERR! node_modules/@material-ui/core
npm ERR!   @material-ui/[email protected]"*" 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 /root/.npm/eresolve-report.txt for a full report.

Looking at the log above, the react version is 17.0.1, while The react version supported by material-ui / [email protected] was 16.8.0. (= Not compatible with the latest React project.) So, I couldn't resolve the dependency and got an error, so I couldn't install it. ..

Now, after npm install, I added ** --save --legacy-peer-deps ** as an option. Then, the installation is completed successfully.

When you do npm install, if the version of the library you are installing does not correspond to the version of the project you are installing to Optional, semi-forced by using ** --legacy-peer-deps **? It seems that you will be able to install. However, after installation, it seems necessary to make sure that the package works as expected.

npm install --save --legacy-peer-deps @material-ui/core

added 29 packages, removed 2 packages, and audited 1720 packages in 18s

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

found 0 vulnerabilities

Impressions

When using a library, what version does the latest version of the library correspond to? I felt once again that I should thoroughly investigate before implementing it. The latest version easily! Is Abunai. ..

Helpful article: https://github.com/mui-org/material-ui/issues/23306

Recommended Posts

ERESOLVE unable to resolve dependency tree
Output XML tree to file
[Resolve LoadError] Unable to autoload constant HomeController, expected /home/vagrant/work/bookers1_debug/app/controllers/home_controller.rb to define it