Closed3
Tamagui環境でesbuildがエラーを起こす

yarnした際に下記のエラーが急に発生した。
➤ YN0009: │ esbuild@npm:0.19.2 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/l8/y3wgn7lx5w7btqf98vzd00d40000gn/T/xfs-9c8df5ef/build.log)
➤ YN0009: │ esbuild@npm:0.21.5 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/l8/y3wgn7lx5w7btqf98vzd00d40000gn/T/xfs-43be98e4/build.log)
➤ YN0009: │ esbuild@npm:0.21.5 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/l8/y3wgn7lx5w7btqf98vzd00d40000gn/T/xfs-084cfaae/build.log)
➤ YN0009: │ esbuild@npm:0.14.47 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/l8/y3wgn7lx5w7btqf98vzd00d40000gn/T/xfs-54dceed3/build.log)
➤ YN0009: │ esbuild@npm:0.24.0 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/l8/y3wgn7lx5w7btqf98vzd00d40000gn/T/xfs-c28f5f57/build.log)
➤ YN0009: │ esbuild@npm:0.21.5 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/l8/y3wgn7lx5w7btqf98vzd00d40000gn/T/xfs-2a6b0875/build.log)
➤ YN0009: │ esbuild@npm:0.21.5 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/l8/y3wgn7lx5w7btqf98vzd00d40000gn/T/xfs-1869803d/build.log)
➤ YN0009: │ esbuild@npm:0.17.19 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/l8/y3wgn7lx5w7btqf98vzd00d40000gn/T/xfs-02809908/build.log)
エラーログは下記
Error: Command failed: /Users/name/.nvm/versions/node/v18.19.0/bin/node /Users/name/tamagui/frontend/node_modules/vitest/node_modules/esbuild/bin/esbuild --version
/Users/name/tamagui/frontend/node_modules/vitest/node_modules/esbuild/bin/esbuild:1
����
SyntaxError: Invalid or unexpected token
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1274:20)
at Module._compile (node:internal/modules/cjs/loader:1320:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
at Module.load (node:internal/modules/cjs/loader:1197:32)
at Module._load (node:internal/modules/cjs/loader:1013:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49

ChatGPTに聞くと
このエラーは高確率で 壊れたバイナリ や 間違ったプラットフォーム用の esbuild が node_modules にあることで発生しています。上記の手順でクリーンに再インストールすれば基本的に解決します。
ということなので、rootの./node_modulesを削除してyarnし直しで治った。
AIはesbuildの個別の入れ直しなどを指示してきたが、エラーログはnode_modules内のesbuildでエラーを吐いていたので多分こっちのほうが早い気がする。

最初、next.js内のnode_modulesを削除してyarnし直していて治らずに焦った・・・
このスクラップは5ヶ月前にクローズされました