0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VS CodeでFormatterがうまく動かないときに確認すること

Last updated at Posted at 2024-09-26

対象読者

VS Codeで保存時にオートでFormatterを通したくて設定を一通り終えた人
まだ終えてない人はこちらから→( https://biomejs.dev/ja/guides/integrate-in-editor/
こういうの出て、「いろいろ設定はしたはずなんだけど……」な時に読んでください
image.png

Extension 'Biome' is configured as formatter but it cannot format 'TypeScript JSX'-files
Extension 'Prettier' is configured as formatter but it cannot format 'JSON'-files

間のFormatterとかファイル形式とかは適宜読み替えてください。

結論

VS Codeで開くフォルダを間違えている

どういうこと?

たとえば今、D:\Projects\flamsを開いたワークスペースがあるとします。
npx create-remix@latestでremixのアプリを作ります。(ReactでもNext.jsでも可)
image.png

名前をflams-frontpageにしました。
すると、何も考えなければ今開いているフォルダの一つ下の階層にできあがります。
image.png

まさしくこれが原因です。
BiomeやPrettierなどのFormatterはワークスペース直下を読みに行くらしく、こんなエラーが出ていました。

Could not resolve Biome in the dependencies of workspace folder: d:\Projects\flams
Searching for Biome in PATH
Extension bundle does not include the prebuilt binary

そりゃ読めませんよね……アプリはその1階層下なので……

ということで、ワークスペースで開くフォルダを変更しましょう。
好きな方法でよいですが、たとえばNew WindowOpen Folderなど。
image.png
image.png

先ほど作ったアプリのフォルダを直接開きに行きます。
image.png

うまくいきました。なんという罠でしょうか。
image.png

「せっかくVS CodeのDefault Formatterに設定したのになんかぜんぜん通らないんだけど」という人に届いてほしいです。
なんだか「Next.jsでBiome使おうと思ったのにVS Codeで自動フォーマット動かないしPrettierでいいや……」→「あれPrettierも動かないや……」みたいな例があるっぽいので……おれもそうだったので……

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?