最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Material-UI Can't resolve '@material-uicorestylescreateMuiTheme - Stack Overflow

programmeradmin3浏览0评论

I know people have posted similar question on StackOverflow, but nothing worked for me, the errors are not the same nor are the fixes, so I am creating a new post.

The firm that is testing me sent me their Github repository and I need to check out that code, it is a Telegram Web app and they are using Material-UI for their design, I cloned the repo installed node_modules and then I got the error from Material-UI ,I followed instructions from other StackOverflow posts but nothing worked for me, uninstalled @material-ui/core and @material-ui/icons, installed them again and still got the same error.

I have tried both NPM and Yarn for installation and nothing. Hope you can help, it is important.

./src/Theme.js
Module not found: Can't resolve '@material-ui/core/styles/createMuiTheme' in '/Users/Faruk/Desktop/int/telegram-react/src'

I know people have posted similar question on StackOverflow, but nothing worked for me, the errors are not the same nor are the fixes, so I am creating a new post.

The firm that is testing me sent me their Github repository and I need to check out that code, it is a Telegram Web app and they are using Material-UI for their design, I cloned the repo installed node_modules and then I got the error from Material-UI ,I followed instructions from other StackOverflow posts but nothing worked for me, uninstalled @material-ui/core and @material-ui/icons, installed them again and still got the same error.

I have tried both NPM and Yarn for installation and nothing. Hope you can help, it is important.

./src/Theme.js
Module not found: Can't resolve '@material-ui/core/styles/createMuiTheme' in '/Users/Faruk/Desktop/int/telegram-react/src'
Share Improve this question edited Oct 31, 2021 at 8:15 NearHuscarl 81.3k22 gold badges318 silver badges280 bronze badges asked Aug 24, 2021 at 17:24 Faruk SuljagicFaruk Suljagic 1081 gold badge1 silver badge8 bronze badges 4
  • What version of Material-UI are you using? – Ryan Cogswell Commented Aug 24, 2021 at 17:58
  • The version is @material-ui/[email protected] – Faruk Suljagic Commented Aug 24, 2021 at 18:16
  • I think the problem was with another developer not importing it correctly, I used a different import and it worked but now there is a strikethrough on the createMuiTheme on Import import { c̶r̶e̶a̶t̶e̶M̶u̶i̶T̶h̶e̶m̶e̶ } from "@material-ui/core/styles"; – Faruk Suljagic Commented Aug 24, 2021 at 18:19
  • 2 That's because the name is changing to createTheme in v5, so in the latest version of v4 both names are exported but createMuiTheme is deprecated. – Ryan Cogswell Commented Aug 24, 2021 at 18:22
Add a comment  | 

3 Answers 3

Reset to default 18

As @Ryan mentioned, createMuiTheme has been renamed to createTheme in the latest v4 and in v5. See the migration guide here for reference.

V5

import { createTheme } from '@mui/material/styles';

V4

import { createTheme } from '@material-ui/core/styles';

If you are using material UI V5 or higher, this works;

import { createTheme } from '@mui/material/styles';

Don't know about createMuiTheme. but you can use this for importing Styles in Mui. This solved mine on importing styles only,

import styled from '@material-ui/core';

Also it works for Material-ui Box, Paper, Link, Grid all of them. Use like this,

import { Grid, Link, makeStyles, Paper,Box, styled} from '@material-ui/core';

But I'm not sure with your theme .

发布评论

评论列表(0)

  1. 暂无评论