【问题标题】:VS Code Prettier - Code Formatter Extension not working with Create-React-App using Typescript templateVS Code Prettier - Code Formatter Extension 不适用于使用 Typescript 模板的 Create-React-App
【发布时间】:2020-11-15 06:14:13
【问题描述】:

我目前正在尝试使用 Create-React-App 启动包和 TypeScript 模板设置应用程序。它的初始安装非常顺利。但是,当我尝试在 VS Code 中使用 Prettier-Code Formatter 扩展程序在保存时自动格式化我的文件时,我得到了错误:

检测到无效的 prettier 配置文件。详情见日志。

日志详细信息基本上只是重申该错误消息。我不确定是什么原因造成的。我试过添加一个 .prettierrc 文件,以及在 package.json 文件中添加配置,都无济于事。

任何帮助将不胜感激。谢谢。

【问题讨论】:

    标签: typescript visual-studio-code create-react-app prettier


    【解决方案1】:

    在您的 vs 代码中打开 File->preferences->Setting 然后打开您的 setting.json 并将其放入其中:

    "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true}
    

    【讨论】:

    • 我认为这不是问题所在。 OP 确实使用 Prettier,但它崩溃了
    猜你喜欢
    • 2021-08-17
    • 2019-11-16
    • 2018-11-30
    • 2021-05-22
    • 2019-09-24
    • 2021-07-10
    • 2018-03-11
    • 2020-04-13
    • 2021-01-06
    相关资源
    最近更新 更多