Nodemon
Nodemon is a development utility that automatically restarts Node.js applications when file changes are detected in the directory. It serves as a replacement wrapper for the `node` command, requiring no code modifications to integrate. The current stable version is 3.1.14, and the project maintains an active release cadence, frequently publishing minor updates and bug fixes.
Common errors
-
nodemon: command not found
cause Nodemon is not installed globally or is installed locally and not executed via `npx` or an npm script.fixInstall globally: `npm install -g nodemon`. If installed locally, run with `npx nodemon your-app.js` or via an npm script. -
script.start with missing file
cause Nodemon attempted to start a script specified in `package.json` (via `main` or `scripts.start`) or on the command line, but the file does not exist or the path is incorrect.fixEnsure the script file exists at the specified path and that the `main` or `scripts.start` entry in `package.json` is correct. -
Nodemon is not watching nested paths or subdirectories for changes.
cause This could be due to an older version of Nodemon (fixed in v3.1.6) or an incorrect `watch` or `ignore` configuration in `nodemon.json`.fixUpdate Nodemon to the latest version (`npm update nodemon`). Verify your `nodemon.json` does not accidentally ignore the directories you want to watch or explicitly configure `"watch": ["src/"]`. -
TypeError: Property 'restart' does not exist on type 'Nodemon' or similar TypeScript type errors related to Nodemon configuration options like 'ignore'.
cause Your `@types/nodemon` package is outdated or incompatible with your installed `nodemon` version, or there's a missing type definition for a newer feature.fixUpdate Nodemon and its corresponding TypeScript types: `npm update nodemon @types/nodemon`. -
Nodemon is not detecting file changes on Windows.
cause There are known platform-specific issues with file system watching on Windows that have been addressed in recent Nodemon versions.fixUpdate Nodemon to the latest version (`npm update nodemon`) to ensure you have the most recent fixes for Windows compatibility.
Warnings
- gotcha When installing Nodemon locally (`npm install --save-dev nodemon`), the `nodemon` command will not be directly available in your system's PATH. You must run it via an npm script or by using `npx nodemon`.
- gotcha Nodemon is a command-line wrapper. You should replace `node` with `nodemon` when executing your script, e.g., `nodemon your-app.js`. Do not try to run it as `node nodemon your-app.js`.
- gotcha Nodemon allows configuration through command-line arguments, local `nodemon.json`, and global `nodemon.json` files. Command-line arguments always take precedence over local config, which in turn overrides global config.
- gotcha If your `package.json` has a `main` property or a `scripts.start` command, Nodemon will automatically attempt to use that script if no specific file is provided on the command line. This can lead to running a different script than expected.
- gotcha Nodemon is designed as a command-line tool and is not intended for direct `import` or `require` into your application code. It operates as an external process manager.
Install
-
npm install nodemon -
yarn add nodemon -
pnpm add nodemon
Quickstart
npx nodemon ./src/index.ts