Node.js CLI Recipes/Run in watch mode

Restart the process when files change.

Section: Watch Mode, Test Runner, and REPL

Run in watch mode

bash
bash
node --watch app.js
Explanation

Built-in watch mode is stable in current Node releases and useful for local development.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Watch Mode, Test Runner, and REPL
Watch specific paths
Only restart when selected paths change.
OpenIn sheetbashsame section
Watch tests
Re-run tests when files change.
OpenIn sheetbashsame section
Run built-in test runner
Execute tests using Node's built-in runner.
OpenIn sheetbashsame section
Start the REPL
Open the interactive Node shell.
OpenIn sheetbashsame section
Persist REPL history
Use a custom history file for REPL commands.
OpenIn sheetbashsame section
Use Node in a shebang script
Create a portable Node-based CLI script.
OpenIn sheetbashsame section