💭
【Nuxt】Dockerでnuxt dev実行するとたまに起動できなくなる場合の解決法
日本語の文献がなかったので追加しておきます。
nuxtを起動させると、たまにこのようなエラーが発生して動かなくなります。
[nitro] [uncaughtException] Error: listen EADDRINUSE: address already in use /tmp/nitro/worker-39-2.sock
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at __node_internal_uvExceptionWithHostPort (node:internal/errors:593:12)
at Server.setupListenHandle [as _listen2] (node:net:1800:21)
at listenInCluster (node:net:1865:12)
at Server.listen (node:net:1964:5)
at <anonymous> (/app/node_modules/nitropack/dist/runtime/entries/nitro-dev.mjs:39:25)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
code: ‘EADDRINUSE’,
errno: -98,
syscall: ‘listen’,
address: ‘/tmp/nitro/worker-39-2.sock’,
port: -1
}
--------------------------------------------
[nitro] [dev] [uncaughtException] Error: listen EADDRINUSE: address already in use /tmp/nitro/worker-73-1.sock
at Server.setupListenHandle [as _listen2] (node:net:1468:21)
at listenInCluster (node:net:1533:12)
at Server.listen (node:net:1632:5)
at file:///app/.nuxt/dev/index.mjs:496:8
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:528:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '/tmp/nitro/worker-73-1.sock',
port: -1
}
解決法
nuxt dev
実行コマンドの前に、/tmp/nitro
をつけると動作します。
rm -rf /tmp/nitro && nuxt dev
Dockerの場合は、CMDで実行すると動作しました。
CMD ["sh", "-c", "rm -rf /tmp/nitro && nuxt dev"]
Discussion