When running Nest in start:dev
mode, make sure to set deleteOutDir
to false
in the nest-cli.json
configuration file:
{
"compilerOptions": {
"deleteOutDir": false
}
}
Also, add the following to your .gitignore
file to avoid committing build artifacts:
dist // or your chosen output directory
*.tsbuildinfo
This is important because, in watch mode (--watch
), TypeScript relies on the .tsbuildinfo
file. This file helps TypeScript to recompile only the files that have changed. If the output directory were deleted on every build, you’d lose the cached, unmodified files, slowing down the build process.