使用yarn install安装material-ui依赖报错,未生成node_modules
解决Yarn安装Material-UI依赖时的YN0057 glob模式报错
问题现象
执行yarn install搭建Material-UI本地环境时,未生成node_modules文件夹,触发一系列YN0057错误,核心提示为依赖覆盖配置使用了已被移除的glob模式,示例报错:
@mui/monorepo: The override for '/@babel/core' includes a glob pattern. Glob patterns have been removed since their behaviours don't match what you'd expect. Set the override to '@babel/core' instead. ➤ YN0057: │ @mui/monorepo: The override for '/@babel/code-frame' includes a glob pattern. Glob patterns have been removed since their behaviours don't match what you'd expect. Set the override to '@babel/code-frame' instead.
修复步骤
- 打开项目根目录的
package.json文件 - 找到
overrides(Yarn 2+)或resolutions(Yarn 1.x)字段 - 将所有带glob通配符的依赖项修改为精确包名:
- 把
"/@babel/core"替换为"@babel/core" - 把
"/@babel/code-frame"替换为"@babel/code-frame" - 把
"**/@babel/plugin-proposal-class-properties"替换为"@babel/plugin-proposal-class-properties"
- 把
- 保存文件后重新执行安装命令:
yarn install
额外排查方案
- 若使用MonoRepo仓库,切换至稳定版本分支,避免开发分支的未成熟配置
- 缓存导致的异常可尝试清除缓存后重装:
yarn cache clean yarn install
内容的提问来源于stack exchange,提问作者Piyush Yadav
相关产品推荐
相关产品推荐

