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]実行時に `Cannot find module *-darwin-x64` というエラーが表示される

Posted at

はじめに

bun を使って Vite で環境構築した際に、 title のエラーが発生したので解消法をまとめておきます

問題

Bun を使って Vite や Biome などの CLI を使おうとすると、ネイティブモジュールが見つけられないというエラーが発生する

bun run vite

Error: Cannot find module @rollup/rollup-darwin-x64. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.

解決方法

--bunフラグを付与する

bun run --bun vite

Bunは独自のJavaScriptエンジンを使用しているらしく、Node.jsとネイティブモジュールの扱い方が異なるようです
--bun フラグを使用する事で、Bunの独自実装を使用することを指定することができエラーを回避できるようです

参考

https://github.com/oven-sh/bun/issues/11511
https://bun.sh/docs/cli/run#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?