Search code examples
typescriptnext.jsnodemon

Why is nodemon not reacting to changes in my src/ folder?


When files inside of subdirectories of my src/ folder are changed, nodemon won't react to their changes, however it will react when other files in project are changed.

Screenshot of the folder structure

package.json:

    "dev": "nodemon src/server.ts",

nodemon.json: *

{
   "watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/server.ts"],
   "exec": "ts-node --project tsconfig.server.json"
}

ts.config.server.json:

    "extends": "./tsconfig.json",
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2017",
        "noEmit": false,
        "outDir": "build/"
    },
    "include": ["src/server.ts"]
}

and ts.config.json:

    "compilerOptions": {
        "target": "esnext",
        "module": "esnext",
        "jsx": "preserve",
        "lib": ["dom", "es2017"],
        "baseUrl": ".",
        "moduleResolution": "node",
        "strict": true,
        "allowJs": true,
        "noEmit": true,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "skipLibCheck": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "isolatedModules": true,
        "removeComments": false,
        "preserveConstEnums": true,
        "sourceMap": true,
        "forceConsistentCasingInFileNames": true,
        "resolveJsonModule": true
    },
    "exclude": ["dist", ".next", "out", "next.config.js"],
    ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}

Solution

  • In nodemon.json try changing this:

    "watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/server.ts"],
    

    to this:

    "watch": [".babelrc", "public/locales/**/*.json", "next.config.js", "src/**/*.ts"],