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

Prettier 3.0.0 TypeError报错求助:prettier.resolveConfig.sync不是函数

问题解决方案

问题根源

prettier 3.0.0 移除了 prettier.resolveConfig.sync 方法,但你当前使用的 eslint-plugin-prettier@4.2.1 仍依赖该方法,版本不兼容导致触发报错。

两种解决办法

办法一:降级 prettier 到 2.x 版本

修改 package.json 中的 prettier 版本为兼容的 2.x 稳定版,例如:

"prettier": "^2.8.8"

然后执行以下命令重新安装依赖:

rm -rf node_modules package-lock.json
npm install

办法二:升级 eslint-plugin-prettier 到适配 prettier 3.x 的版本

eslint-plugin-prettier@5.0.0 及以上版本已适配 prettier 3.x,修改 package.json 中的对应版本:

"eslint-plugin-prettier": "^5.0.0"

同样执行重装依赖的命令:

rm -rf node_modules package-lock.json
npm install

验证

重新执行 eslint 命令:

npx eslint "the code directory"

确认报错消失即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 08:34:55