9

I am using react Material UI, and I received the following error.

"Module not found: Can't resolve '@material-ui/icons/Lock'"

import LockIcon from '@material-ui/icons/Lock';

How can I fix this?

2
  • 2
    could you add the package.json file to see the dependencies. Commented Sep 20, 2018 at 8:53
  • In case you have installed UI icons, the import statement might need a change.. try `import {LockIcon} from 'material-ui/icons' Commented Sep 20, 2018 at 10:14

6 Answers 6

15
import Icon from '@material-ui/core/Icon';

then add font material icons to index.html

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
Sign up to request clarification or add additional context in comments.

Comments

0

You haven't installed @material-ui/icons package. You can validate it from node_modules


This would resolve your issue,

npm install --save @material-ui/icons

Comments

0

MUI have since separated their icons from core into a separate node_module called @material-ui/icons.

Here's a good example on how to setup your MUI Icons with React: https://mechanicalrock.github.io/2021/04/27/fed-talk-s01e01-getting-started#keyboard-getting-started-with-material-ui

Comments

0

Here's an alternative is you cant install the node modules:

  1. Add "" to your head tag, or whever you store your links to style sheets.
  2. Add a span tag with class name "material-icons" and make the content of the span the icon you want to use. example: menu

You can find more info about all the icons here

Comments

0

This syntax worked for me in React import VolumeUp from '@mui/icons-material/VolumeUp'

and you must install npm i --save '@mui/icons-material'

You can find more info here and a React Code Generator here

Comments

0

Install the library

"npm install @material-ui/icon --force"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.