likes
comments
collection
share

使用yarn安装依赖报错的解决方法:Browserslist: caniuse-lite is ou

作者站长头像
站长
· 阅读数 32

问题描述

执行命令 yarn 报如下错误

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

问题分析及解决方案

原因分析:错误已经提示的很明显了,Browserslist中的依赖已经更新了,需要升级Browserslist包,否则无法使用。按照提示,执行如下命令

npx browserslist@latest --update-db

在webstorm中的problems面板中,已经没有报包未安装的提示了

使用yarn安装依赖报错的解决方法:Browserslist: caniuse-lite is ou

如果还没解决,可执行如下两个命令

rm -rf node_modules   // 删除node_modules包
yarn cache clean  // 清空yarn的缓存

执行 npm run dev 启动项目,一切正常,搞定

遇到问题的建议:

遇到问题一定要看清错误提示

不要自己瞎折腾,比如:

  • 删除node_module包,反复重新安装;
  • 换其他的安装方式 npm ,cnpm等;
  • 强制执行npm run dev, 看到一堆未安装的包,然后一次安装

未定位清除问题,瞎猜太浪费时间了