Software Engineering :: Programming :: Languages :: JavaScript :: Runtimes :: Node.js :: Watch :: Tutorial :: Using Node Watch Instead of Nodemon
⪼ Made with 💜 by Polyglot.
To use this feature you’ll need to pass the
--watchflag to your command followed by the name of the file. If you wanted to run a file namedserver.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
This feature is available under a feature flag in Node 18.11+ and generally available in Node 19.