LoginSignup
0
0

More than 1 year has passed since last update.

VSCode settings.json エラー

Last updated at Posted at 2021-06-20

VSCodeで「ユーザー設定に書き込めません。ユーザー設定を開いて、ファイル内のエラー/警告を修正してからもう一度お試しください。」というエラーが発生した。
VSCode setting.jsonエラーメッセージ.jpg

{
    "todo-tree.tree.showScanModeButton": false,
    "workbench.iconTheme": "vscode-icons",
    "editor.tabSize": 2,
    "editor.wordWrap": "on",
    "files.autoSave": "afterDelay",
    "editor.fontFamily": "Ricty Diminished",
    "editor.minimap.enabled": false,
    "python.pythonPath": "C:\\Users\\admin\\anaconda3\\envs\\py38\\python.exe",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "html.autoClosingTags": true,
    "files.associations": {
        "*.html": "html"
    },
    "window.zoomLevel": 1,
    "workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb",
            "filenamePattern": "*.ipynb"
        }
    ]
    "files.trimTrailingWhitespace": true
    //"python.pythonPath": "C:\\Users\\admin\\anaconda3\\envs\\py38",
    //"python.condaPath": "C:\\Users\\admin\\Anaconda3\\Scripts\\conda.exe"
    "files.associations": {
        "*.erb": "erb"
    }
    "emmet.includeLanguages": {
        "erb": "html"
    }
}
  • 実際のsetting.json VSCode setting.jsonエラー.jpg

なにがおきているのか。。

  • ①拡張機能のOpen with Live Serverも使えなくなってる。
  • ②htmlファイルの言語モードが「Djnago Template」になってしまっていて、HTMLに切り替えてもすぐ「Djnago Template」に戻ってしまう。

それぞれのプロパティの中にカンマがなかったことが原因だったよう。
とりあえずエラーのダイアログは表示されなくなったが①と②は解消されないので調査継続。

②は言語モードをDjango TemplateからHTMLに変更したら直った。

  • 修正前
    言語モードDjango Template.jpg

  • 修正後
    言語モードHTML.jpg

ただ、これ1ファイルずつ変えていかなきゃいけないのか。。

①はHTMLファイルを開いて↓のGo Liveをクリックしたら同じ挙動になった。
言語モードHTML.jpg

ただ以前はHTMLファイルを右クリックしたら「Open with Live Server」が選択できたのに。。

原因

setting.jsonのfiles.associationsが悪さをしていたよう。
files.associationsは「言語に対するファイルの関連付け」をするプロパティ。
なんでかわからんがfiles.associationsが2つ出来てしまっていた。

files.associations": { ".html": "html" }でhtmlファイルを言語モード「HTML」で開く設定にしているのに
ファイル下部のfiles.associationsがファイル上部のfiles.associationsを上書いてしまって、
files.associations": { "
.html": "html" }の設定を削除してしまったことが原因。
VSCode setting.jsonエラー解消後.jpg
ファイル下部の"files.associations": { "*.erb": "erb" }, をコメントしたら
htmlファイルの言語モードがデフォルトでHTMLになった。
htmlファイルを右クリックしてOpen with Live Serverも表示されるようになった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0