Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active May 7, 2024 19:26
Show Gist options
  • Select an option

  • Save wilmoore/4561aff6d38f6e9874b34a2b232f46bc to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/4561aff6d38f6e9874b34a2b232f46bc to your computer and use it in GitHub Desktop.
Software Engineering :: Programming :: Languages :: JavaScript :: Runtimes :: Node.js :: Watch :: Tutorial :: Using Node Watch Instead of Nodemon

Software Engineering :: Programming :: Languages :: JavaScript :: Runtimes :: Node.js :: Watch :: Tutorial :: Using Node Watch Instead of Nodemon

⪼ Made with 💜 by Polyglot.

How To Use

To use this feature you’ll need to pass the --watch flag to your command followed by the name of the file. If you wanted to run a file named server.js, for example, you would run the following:

node --watch server.js

This command will auto-reload your file, but only when that specifc file has changed. Let’s say you want to reload your file anytime any file in a given directory changes. For this, you can use the --watch-path flag followed by the directory and then the file you want to run. If you’re file is inside of a directory called src, you can use the following command:

node --watch-path=./src server.js

Availability

This feature is available under a feature flag in Node 18.11+ and generally available in Node 19.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment