You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法解析'material-ui/FontIcon'模块,请求技术协助

Fix: Module not found: Can't resolve 'material-ui/FontIcon'

Hey there, let's break down why you're hitting this error and walk through the fixes step by step:

Root Cause

You’re using material-ui@1.0.0-beta.40—an early beta build of Material UI v1.x. During the transition from v0.x to v1.x, the FontIcon component was renamed and later moved out of the core material-ui package entirely. That’s why it’s missing from your node_modules folder—it doesn’t exist in this version anymore.

Solutions

1. Swap FontIcon for the core Icon component

In your beta version, FontIcon was replaced by the Icon component in the core package. Update your code like this:

  • Old import:
    import FontIcon from 'material-ui/FontIcon';
    
  • New import:
    import Icon from 'material-ui/Icon';
    
  • Old usage:
    <FontIcon className="material-icons">home</FontIcon>
    
  • New usage:
    <Icon className="material-icons">home</Icon>
    

For a more maintainable solution (and better compatibility with future updates), use the standalone @material-ui/icons package:

  1. First install the package:
    npm install @material-ui/icons --save
    
  2. Import specific icons directly into your component:
    import HomeIcon from '@material-ui/icons/Home';
    
  3. Use the icon component in your UI:
    <HomeIcon />
    

3. Upgrade to a stable Material UI version (Bonus)

Your current beta version is outdated and likely has unpatched bugs. Upgrading to the latest stable release will resolve more potential issues and unlock new features:

npm install material-ui@latest --save

内容的提问来源于stack exchange,提问作者Mr Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:02:51