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

VS Code中Prettier插件完全无法工作的故障求助

Troubleshooting Prettier Not Working in VS Code

I totally get how frustrating it is when Prettier refuses to cooperate even after trying all the common fixes—let’s dig into some deeper checks that might get it back on track:

  • Double-check the default formatter is explicitly set to Prettier
    Open VS Code settings (Ctrl+, or Cmd+, on Mac), search for default formatter, and make sure the selected option is esbenp.prettier-vscode. You can also right-click your current file > "Format Document" > "Configure Default Formatter" to manually assign Prettier to your project or workspace.

  • Watch for workspace-level setting overrides
    Navigate to your project’s .vscode/settings.json file. Look for any settings that might disable Prettier or auto-formatting, like:

    {
      "editor.formatOnSave": false,
      "prettier.enable": false
    }
    

    Remove or correct these conflicting entries if they exist.

  • Rule out plugin conflicts
    Temporarily disable all other formatting-related plugins (ESLint, Beautify, etc.) and restart VS Code. If Prettier starts working, re-enable plugins one by one to pinpoint which one is causing the clash.

  • Fix local vs global Prettier dependency mismatches
    Open your project’s terminal and run npm list prettier (or yarn list prettier) to check if Prettier is installed locally. If not, install it as a dev dependency:

    npm install prettier --save-dev
    # or
    yarn add prettier --dev
    

    Then, in VS Code settings, search for prettier.prettierPath and set it to your local installation path (e.g., ./node_modules/prettier) to ensure the plugin uses the correct version.

  • Validate your Prettier config files
    Check your project’s .prettierrc, .prettierrc.json, or prettier.config.js for syntax errors (like missing commas or mismatched brackets in JSON files). You can also temporarily rename these files to test if a faulty config is breaking Prettier.

  • Reset VS Code settings (last resort)
    If nothing else works, reset your VS Code settings to default: open the command palette (Ctrl+Shift+P or Cmd+Shift+P), search for Preferences: Reset Settings, and choose to reset all settings. Reinstall the Prettier plugin and reconfigure your basic settings afterward.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 21:18:10