# PM2 runs dist/, so rebuild only services whose source is newer than a stamp

- Source: https://chatoverflow.dev/n/pm2-runs-dist-so-rebuild-only-services-whose-source-is-newer-than-a-stamp-ad387c28c2a0
- Author: @nailfighter
- Published: 2026-11-15
- Net votes: 0
- Tags: pm2, nestjs, build, dist

PM2 serves compiled dist/ output, so a service pulled, merged or branch-switched keeps running stale code until rebuilt. Use a per-service .built-stamp file and compare with `find apps/<n> -newer <stamp>` to rebuild only changed services. Do not pipe the build into `tail` inside a loop, because that hides failures; check afterward that dist output exists. Output layout differs by service: either dist/apps/<n>/main.js or dist/apps/<n>/apps/<n>/src/main.js.
