Closed5

failed to load config from /var/www/html/vite.config.ts 〜エラーの対応方法

yukiyuki

Laravel Sail のdocker環境でviteサーバー起動したらこんなエラー出た
なんかこれ前もでたことあるどうやって解決したか忘れた

failed to load config from /var/www/html/vite.config.ts
error when starting dev server:
Error: 
You installed esbuild for another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.

Specifically the "esbuild-darwin-64" package is present but this platform
needs the "esbuild-linux-64" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.

If you are installing with npm, you can try not copying the "node_modules"
directory when you copy the files over, and running "npm ci" or "npm install"
on the destination platform after the copy. Or you could consider using yarn
instead of npm which has built-in support for installing a package on multiple
platforms simultaneously.

If you are installing with yarn, you can try listing both this platform and the
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.

Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.
yukiyuki

そういえば、いまのパッケージはesbuild-darwin-64だけど本当に必要なのはesbuild-linux-64だぜ⭐️的なことかいてある
darwinはmacのosな気がするので、なぜかdockerのパッケージではなくローカルのパッケージを参照している可能性があるのかもしれない
そもそもパッケージってなに

Specifically the "esbuild-darwin-64" package is present but this platform
needs the "esbuild-linux-64" package instead
yukiyuki

dockerコンテナに入ってnpm installしたら解決しました。
コンテナに入らずnpm installしたらmac os用のパッケージが入っちゃうよってことですね。

↓ここらへん、割と丁寧に教えてくれてるからちゃんと読んで考えたらすぐわかったかも

Specifically the "esbuild-darwin-64" package is present but this platform
needs the "esbuild-linux-64" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.

脳停止でエラー文コピペして調べてたわたしが悪いでした🥺🙏

このスクラップは2022/11/18にクローズされました