Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When installing Material UI, I am prompted with a series of errors?

When I attempt to install Material UI using npm install @material-ui/core , I am prompted with many errors:

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!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from @material-ui/[email protected]
npm ERR! node_modules/@material-ui/core
npm ERR!   @material-ui/core@"*" 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 /Users/jordanhilado/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jordanhilado/.npm/_logs/2020-10-31T17_57_54_724Z-debug.log

How can I fix this?

like image 638
dando Avatar asked Oct 31 '20 18:10

dando


People also ask

How do I know if material UI is installed?

You can check your installed material-UI and other packages & versions. Open the package. json file then you can see your installed packages and versions.

How do you add material UI in React project?

We must install the Material-UI to access its different functionalities or components. Open your terminal, and ensure that you are inside your application's master folder. Type npm install @material-ui/core in the terminal and click enter. Run the command below to use Material-UI icons in our project.

What is the difference between material UI and material UI core?

Material UI: the organization is now called MUI. Material UI: the set of foundational MIT React components is now called MUI Core. Material UI: the Material Design components developed by MUI. Also, we ditched the hyphen!


2 Answers

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

Material UI does not officially support React v17 yet, so use with caution.

like image 121
devil Avatar answered Nov 14 '22 21:11

devil


npm ERR! peer react@"^16.8.0" from @material-ui/[email protected]

This line here is giving you a hint as to what is going wrong.

@material-ui/[email protected] is expecting a peer dependency for react to be within the current major version allowed (in this case it seems like they have not added support for React version 17 yet).

It looks like you are on the most recent major version of React 17.0.1. The most recent version of Material-UI will support react version below 17.0.0 currently.

See this other stack overflow for an explanation on what the '^' means in version numbers.

What's the difference between tilde(~) and caret(^) in package.json?

To get around this try downgrading React to version 16, at least until Material-UI adds support for version 17.

A side note: you may not need everything it comes with but create react app is a great way to get started on React projects and not really have to worry about versioning issues.

like image 25
Brady Haden Avatar answered Nov 14 '22 23:11

Brady Haden