nodemon
Restart Node.js application on file changes
TLDR
Execute the specified file and watch a specific file for changes
Manually restart nodemon (note nodemon must already be active for this to work)
Ignore specific files
Pass arguments to the node application
Pass arguments to node itself if they're not nodemon arguments already (e.g. --inspect)
Run an arbitrary non-node script
Run a Python script
SYNOPSIS
nodemon [options] [script.js] [arguments]
PARAMETERS
script.js
The Node.js script to execute. If omitted, nodemon
will try to use the main
property in package.json
or index.js
arguments
Arguments passed to the script.js
when it's executed.-v, --version
Show version number.-h, --help
Show help information.-c, --config <path>
Specify a custom nodemon.json
configuration file.-w, --watch <glob|file|dir>
A file, glob, or directory to watch for changes. Multiple paths can be specified.-i, --ignore <glob|file|dir>
A file, glob, or directory to ignore. Multiple paths can be specified.-x, --exec <command>
The command to execute instead of `node`. E.g., `--exec python`.-e, --ext <extensions>
File extensions to watch (default: js,mjs,cjs,json).-V, --verbose
Show all system details on startup.-q, --quiet
Suppress all output except error messages.--delay <time>
Delay restart in milliseconds (default: 1000ms).--exitcrash
Exit immediately if the script crashes.--legacy-watch
Use legacy watch for file system changes.
DESCRIPTION
Nodemon is a command-line utility that automatically restarts your Node.js application whenever it detects changes in the file system. This eliminates the need to manually restart the server after each code modification, significantly improving developer productivity. It's particularly useful during development and testing. Nodemon monitors the directory containing your script and restarts the process if any file within that directory changes. It also supports configuration files to customize the monitored files, ignored directories, and restart behavior. It's easily installed via npm and can be used as a simple drop-in replacement for the `node` command when starting your application.
CONFIGURATION FILES
Nodemon supports configuration via a nodemon.json
file. This file allows you to specify which files to watch, which files to ignore, and other settings. It can simplify command-line arguments.
SIGNALS
When nodemon restarts your script, it sends a SIGTERM
signal to the previous process. This allows your application to gracefully shut down before the new process starts.