[solved] devtool reloads if application writes to a file

If you are developing a node js application using devtool, you may experience a rather frustrating situation whereby you application stops without any traceable errors followed by a subsequent reload of the devtool.

Why does devtool keep reloading when there are no errors?

There is a likelyhood that you are experiencing this issue as you are developing with fs (file system) and writing to appending to or streaming to a file.

For me, I was in the habit of using devtool with the –watch option. So accustomed to using this option was I that I did so mindlessly. The devtool –watch option performs the task of reloading the devtool whenever the development environment saves a file. Since the file my application was writing to existed within the development environment, the devtool with the –watch option was simply doing what it was designed to do.

Solution: Unwanted reloading of devtool when writing to a file

On solution to unwanted reloading of the devtool when working with the file system (fs) is simply not to use the –watch option with devtool.

Another solution is to write to a file that is outside the immediate development environment.

If you application has the requirement of writing to the file within the development environment, then you can change the location of the file until you have completed development and then move it back to where it is required.

I hope this note has saved you some time and frustration.

Leave a Reply

Your email address will not be published.