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

无法导入@mui/icons-material模块:本地项目均报Module not found错误

解决@mui/icons-material导入失败(Module not found)的方案
  • 切换Node版本到LTS
    Node 20.x与MUI v5、Next.js可能存在兼容性冲突,建议切换到Node 18.x LTS版本:

    nvm install 18
    nvm use 18
    

    切换后删除node_modules、yarn.lock/package-lock.json,重新执行依赖安装。

  • 禁用Next.js SWC编译器
    在next.config.js中添加配置禁用SWC,改用Babel处理:

    module.exports = {
      swcMinify: false,
    };
    

    同时在项目根目录创建.babelrc文件,内容如下:

    {
      "presets": ["next/babel"],
      "plugins": [["@emotion/babel-plugin", { "sourceMap": true }]]
    }
    
  • 强制清理缓存并重装依赖
    若依赖安装缓存导致文件缺失,执行以下命令:

    # Yarn用户
    yarn cache clean --force
    rm -rf node_modules yarn.lock
    yarn install
    
    # npm用户
    npm cache clean --force
    rm -rf node_modules package-lock.json
    npm install
    

    操作后检查node_modules/@mui/icons-material目录下是否存在目标图标文件(如AccountCircleOutlined.js)。

  • 检查TypeScript配置
    确保tsconfig.json的moduleResolution设置正确,避免模块解析异常:

    {
      "compilerOptions": {
        "moduleResolution": "node"
      }
    }
    
  • 修复Homebrew Node权限问题
    macOS下Homebrew安装的Node可能存在权限问题,导致依赖安装不完整,尝试重新安装Node:

    brew uninstall node
    brew install node@18
    brew link --force node@18
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 06:16:25