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?

Bun 環境で Oxc 拡張が動かなかった問題と対処

0
Posted at

Bun をベースイメージにした Dev Containers で VSCode 拡張 Oxc (oxc.oxc-vscode) を使おうとしたら、動かんかった。

環境

  • Visual Studio Code v1.119.0
  • Dev Containers (VSCode 拡張) v0.459.0
  • Bun (コンテナイメージ) v1.3.13
  • Oxc (VSCode 拡張) v1.56.0

エラー詳細

こういうエラーが出る。

Formatting のエラー
Extension 'Oxc' is configured as formatter but it cannot format 'TypeScript'-files
Oxc 拡張の Output
[Error - 12:19:54 AM] Client oxc: connection to server is erroring. Cannot call write after a stream was destroyed
[Error - 12:19:54 AM] Server initialization failed.
[Error - 12:19:54 AM] oxc client: couldn't create connection to server.
[Error - 12:19:54 AM] Restarting server failed
[Info  - 12:19:54 AM] Connection to server got closed. Server will restart.
env: 'node': No such file or directory

原因

Oxc 拡張が Node を使おうとするらしく、Node は入っていないのでエラーが出た。

対応

Bun の公式イメージには Node 互換のためのエイリアスがある。

$ which node
/usr/local/bun-node-fallback-bin/node

$ ls -lh /usr/local/bun-node-fallback-bin/
total 0
lrwxrwxrwx 1 root root 18 Apr 20 08:12 node -> /usr/local/bin/bun

シェルからだと PATH は通っているが、Oxc 拡張からは通っていないので見えないらしい。

.vscode/settings.json
  "oxc.path.node": "/usr/local/bun-node-fallback-bin/node"

これを VSCode 拡張の設定で明示してやることで動くようになった。

所感

Node が入っていなくても勝手に Bun を検知して動いて欲しい〜

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?