无法导入@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
相关产品推荐
相关产品推荐

