Search code examples
node.jstypescriptwebpacknestjsnestjs-config

Prevent automatic server restart when running in watch mode upon making changes to certain folders


I run my NestJS application in watch mode. Normally, whenever I make changes to the file in the code, it restarts the server which is the expected behaviour.

I used the default nest start --watch command to perform this.

However, in certain conditions, I do not want to restart the server.

Take my particular case where I have been testing a file upload from the frontend. Whenever I upload a file into a folder within the codebase, it thinks that I have made changes to the actual codebase. Hence it will automatically restart the server and throwback an unexpected response to the request. I don't want the server to restart when adding a file to the uploads directory.

Please help me fix the problem.


Solution

  • Don't change your server files when running your server. Save your files into folder outside of your repo. You should not download files into your server, they should be stored elsewhere, like a storage service, but not in a codebase.