nodemon.json

Overview

The `nodemon.json` file is a configuration file used by **Nodemon**, a utility that monitors for any changes in your source files and automatically restarts your Node.js application. This file defines specific rules and parameters that control how Nodemon behaves during development, including which files to watch for changes, which files to ignore, the file extensions Nodemon should monitor, and the command to execute when restarting the application.

This configuration is crucial for streamlining the development workflow by automating rebuilds and restarts, thereby improving productivity and reducing manual intervention.


Configuration Properties and Their Purpose

The `nodemon.json` file contains a JSON object with the following keys:

Property

Type

Description

`ignore`

Array of strings

Specifies files or directories that Nodemon should **not** watch for changes. Changes in these files will **not** trigger a restart.

`watch`

Array of strings

Specifies additional files or directories that Nodemon should watch for changes. Nodemon will restart the app when files in these locations change.

`ext`

String

Defines the file extensions Nodemon should monitor for changes. Only files with these extensions will trigger a restart.

`exec`

String

The command that Nodemon will execute when restarting the application. This typically includes build commands and the start command for the app.


Detailed Explanation of Each Property

1. ignore

"ignore": ["src/routes.ts"]

2. watch

"watch": ["../../coinstacks/common/api/dist/tsconfig.tsbuildinfo", "src"]

3. ext

"ext": "ts"

4. exec

"exec": "yarn build && node dist/proxy/api/src/app.js"

Usage Example

You place `nodemon.json` in the root directory of your project. Then, running `nodemon` in the terminal will automatically use this configuration.

nodemon

When you make changes to any `.ts` files inside `src` or the specified `tsconfig.tsbuildinfo` file, Nodemon will:

  1. Run yarn build to compile TypeScript.

  2. Start the app with Node.js using the compiled output dist/proxy/api/src/app.js.

  3. Ignore changes in src/routes.ts to avoid unnecessary restarts.


Important Implementation Details


Interaction with Other Parts of the System


Visual Diagram: Workflow of nodemon.json Configuration

flowchart TD
    A[File Change Detected]
    B{File Extension is .ts?}
    C{File in ignore list?}
    D{File in watch list?}
    E[Ignore Change - No Restart]
    F[Run Command: yarn build && node dist/proxy/api/src/app.js]
    G[Restart Application]

    A --> B
    B -- No --> E
    B -- Yes --> C
    C -- Yes --> E
    C -- No --> D
    D -- Yes --> F
    D -- No --> E
    F --> G

**Explanation:**


Summary

The `nodemon.json` file is a lightweight configuration file that enables efficient development of a TypeScript Node.js application by:

This configuration helps maintain a smooth developer experience by automating rebuilds and restarts while avoiding unnecessary interruptions.