Node.jsNodemonError Fix2026 Updated
Nodemon Not Restarting— File Changes Not Detected [Fixed 2026]
Also covers: watch paths · --ext flag · nodemon.json · TypeScript with tsx · Node.js --watch alternative
January 20265 min readNode.js 18/20/22 · TypeScript · Nodemon
⚡ The Problem
Error
# nodemon running but server doesn't restart on file save
$ nodemon src/index.ts
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
# .ts files not in extension list → changes ignored!✅ Fix — add extensions and exec
Correct nodemon command for TypeScript
nodemon --exec "tsx" --ext "ts,js,json" --watch src src/index.tsWhy nodemon Stops Detecting File Changes
nodemon watches files using the OS file system events (same as Vite). By default it watches the current directory for .js, .mjs, .cjs, and .json files. TypeScript .ts files are not watched by default — you must add them with --ext .
12 min
Specify Watch Paths Explicitly
nodemon not watching the right directory--watch flag — specify directories
# ❌ Watches everything in cwd including node_modules (slow)
nodemon index.js
# ✅ Watch only src directory
nodemon --watch src index.js
# ✅ Watch multiple directories
nodemon --watch src --watch config index.js
# ✅ Watch specific file
nodemon --watch src/config.json index.js22 min
Add File Extensions nodemon Should Watch
TypeScript or other file types not triggering restart--ext flag — file extensions to watch
# Default extensions: js,mjs,cjs,json
# TypeScript not included — add ts,tsx:
nodemon --ext "js,ts,json" src/index.ts
# Full TypeScript + config files:
nodemon --ext "js,ts,tsx,json,yaml,yml" src/index.ts
# package.json scripts:
{
"scripts": {
"dev": "nodemon --ext 'ts,js,json' --exec 'tsx' src/index.ts"
}
}33 min
Use nodemon.json for Full Configuration
Long CLI flags — centralise in config filenodemon.json — complete configuration
{
"watch": ["src", "config"],
"ext": "ts,js,json,yaml",
"ignore": [
"src/**/*.spec.ts",
"src/**/*.test.ts",
"dist/",
"node_modules/",
"*.log"
],
"exec": "tsx src/index.ts",
"delay": 500,
"env": {
"NODE_ENV": "development"
}
}
// package.json — just run nodemon (picks up nodemon.json automatically):
{
"scripts": {
"dev": "nodemon"
}
}
// Or point to config explicitly:
{
"scripts": {
"dev": "nodemon --config nodemon.json"
}
}43 min
Use tsx or ts-node for TypeScript Projects
TypeScript files need a runtime — nodemon can't run .ts directlyTypeScript executors with nodemon
# Install tsx (recommended — fast, no config needed)
npm install -D tsx
# Run TypeScript with nodemon + tsx
nodemon --exec "tsx" --ext "ts,js" --watch src src/index.ts
# Or with nodemon.json:
{ "exec": "tsx src/index.ts", "ext": "ts,js,json" }
# Alternative — ts-node (slower, needs tsconfig)
npm install -D ts-node
nodemon --exec "ts-node" --ext "ts" src/index.ts
# For ESM TypeScript:
nodemon --exec "tsx" --ext "ts" src/index.ts
# tsx handles ESM natively — no extra flags needed
# package.json scripts:
{
"scripts": {
"dev": "nodemon --exec tsx --ext ts,js --watch src src/index.ts",
"dev:config": "nodemon" // uses nodemon.json
}
}tsx is the fastest TypeScript executor for development — no compilation step, native ESM support, and works with path aliases from tsconfig. Install it with npm install -D tsx and use it as the nodemon exec.
52 min
Use Node.js --watch Flag (Node 18+) Instead
Simple projects — built-in watch without nodemon dependencyNode.js --watch — zero dependency alternative
# Node.js 18+ built-in watch mode — no nodemon needed
node --watch src/index.js
# With tsx for TypeScript (Node 18+):
tsx --watch src/index.ts
# package.json:
{
"scripts": {
"dev": "node --watch src/index.js",
"dev:ts": "tsx --watch src/index.ts"
}
}
# Node --watch-path — watch additional directories:
node --watch --watch-path=./config src/index.js
# Ignore patterns (Node 22+):
node --watch --watch-path=src --ignore-watch=src/generated src/index.js
# When to use --watch vs nodemon:
# --watch: simple projects, single entry point, no ignore patterns
# nodemon: complex watch configs, multiple extensions, legacy projectsPrevention
- Always add --ext ts,js,json when working on TypeScript projects — .ts is not watched by default
- Use nodemon.json to centralise config — avoids long CLI flags and ensures consistency across team
- Use tsx as the exec for TypeScript — faster than ts-node, no separate tsconfig needed
- Add ignore patterns for dist/, *.log, and *.spec.ts to avoid restart loops
- For Node 18+ simple projects, use tsx --watch src/index.ts — zero dependencies
- On Linux/WSL2, increase inotify watches if nodemon randomly stops detecting changes
Frequently Asked Questions
Why is nodemon not restarting when I save a file?+−
The most common causes are: the changed file is in a directory not watched by nodemon (defaults to the current directory), the file extension is not in nodemon's watch list (defaults to .js, .mjs, .json), or the file path matches an ignore pattern like node_modules. Add --watch and --ext flags or configure nodemon.json.
How do I make nodemon watch TypeScript files?+−
Add --ext ts,js to the nodemon command, and use tsx or ts-node-esm as the executor: nodemon --exec 'tsx src/index.ts' --ext ts,js. This tells nodemon to watch .ts files and use tsx to run them directly without a separate compile step.
What is the difference between nodemon --watch and --ext?+−
--watch specifies which directories or files to monitor. --ext specifies which file extensions trigger a restart. Both are needed for non-standard setups: --watch src tells nodemon to watch the src directory, --ext ts,js,json tells it which file types in that directory to react to.
Why does nodemon restart on every save even without changes?+−
Nodemon is probably watching generated output files that change when nodemon restarts (e.g. TypeScript compile output). Use --ignore to exclude build directories: nodemon --ignore dist/ --ignore .next/. Also exclude log files and temporary files that your app writes during startup.
What is the Node.js --watch flag and should I use it instead of nodemon?+−
Node.js 18+ has a built-in --watch flag that restarts the process when imported files change. It is simpler and requires no dependencies. Use node --watch src/index.js for simple projects. For TypeScript, combine it with tsx: tsx --watch src/index.ts. For complex setups with ignore patterns and multiple extensions, nodemon still has more configuration options.
Can I use nodemon with ES modules (ESM)?+−
Yes, but you may need to set --experimental-specifier-resolution=node or use an .mjs extension. For ESM TypeScript, use tsx which natively handles ESM: nodemon --exec 'tsx src/index.ts'. Alternatively, use the Node.js --watch flag which has better native ESM support.
Need Expert Help?
We Build Production Node.js Backends
Softplix engineers build Node.js and Express APIs with TypeScript, proper watch configuration, and production-ready deployments. Let us help.
Talk to an Engineer