Tanstack Router + Vite race condition in filewatcher (EPERM)

작성자

카테고리:

← 피드로
DEV Community · Sekti Wicaksono · 2026-07-09 개발(SW)

Sekti Wicaksono

Recently I got an issue when creating a new route using Tanstack Router + Vite

So by adding this config could solved the issue of EPERM: operation not permitted like below:

Error: EPERM: operation not permitted, rename 'D:IMTimt-fe.tanstacktmp884d3334-4715af826dad72bfa663dbba03a36060' -> 'D:IMTimt-fesrcroutesusers$phone_numberedit.tsx'
>     at file:///D:/IMT/imt-fe/node_modules/@tanstack/router-generator/dist/esm/generator.js:143:13
>     at async generate (file:///D:/IMT/imt-fe/node_modules/@tanstack/router-plugin/dist/esm/core/router-generator-plugin.js:39:4)
>     at async PluginContext.watchChange (file:///D:/IMT/imt-fe/node_modules/@tanstack/router-plugin/dist/esm/core/router-generator-plugin.js:49:4)
>     at async Promise.all (index 1)
>     at async EnvironmentPluginContainer.hookParallel (file:///D:/IMT/imt-fe/node_modules/vite/dist/node/chunks/node.js:29604:3)
>     at async EnvironmentPluginContainer.watchChange (file:///D:/IMT/imt-fe/node_modules/vite/dist/node/chunks/node.js:29771:3)
>     at async Promise.all (index 0)
>     at async onFileAddUnlink (file:///D:/IMT/imt-fe/node_modules/vite/dist/node/chunks/node.js:25530:3)

Enter fullscreen mode Exit fullscreen mode

By adding usePolling and stabilityThreshold props into vite.config.ts, the route creation happen like magic during development process (a bit slow but your server won’t shut)

vite.config.ts

const config = defineConfig({
  .... your other config ....
  // solves EPERM 
  server: {
    watch: {
      usePolling: true,
      interval: 300,
      awaitWriteFinish: {
        stabilityThreshold: 500,
        pollInterval: 100,
      },
    }
  }
})

Enter fullscreen mode Exit fullscreen mode

Note: This config doesn’t depend on specific OS/hardware settings. If you still encounter similar issues when generating multiple routes at once, simply increase the stabilityThreshold interval slightly (e.g., 500 → 800) as a further adjustment.

원문에서 계속 ↗

코멘트

답글 남기기