nodemon.json


Overview

The `nodemon.json` file serves as a configuration file for **Nodemon**, a utility that monitors changes in source files and automatically restarts the Node.js application. This file defines which files and directories Nodemon should watch for changes, which files to ignore, the file extensions to monitor, and the command to execute when changes are detected.

In this specific configuration, Nodemon is set up to:

This setup is especially useful in TypeScript projects where source files need to be compiled before execution.


Detailed Explanation

JSON Structure and Properties

Property

Type

Description

Example Value

`ignore`

Array of strings

Lists files or directories that Nodemon should **ignore**; changes in these files won't trigger a restart.

["src/routes.ts"]

`watch`

Array of strings

Specifies files or directories Nodemon should **watch** for changes to trigger restarts.

["../../../packages/*/dist/tsconfig.tsbuildinfo", "src"]

`ext`

String

Defines the file extensions Nodemon should monitor. Only changes in these file types trigger restarts.

`"ts"`

`exec`

String

The command that Nodemon runs when a watched file changes. Typically used to build and run the application.

"yarn build && node dist/avalanche/api/src/app.js"


Usage Example

To use this configuration, simply run Nodemon with the configuration file:

nodemon --config nodemon.json

This will:

  1. Watch the specified files and directories for .ts file changes.

  2. Ignore changes in src/routes.ts.

  3. Upon detecting relevant changes, run yarn build to compile TypeScript files.

  4. Start the Node.js application by executing node dist/avalanche/api/src/app.js.


Important Implementation Details


Interaction with Other Parts of the System


Mermaid Diagram: Workflow of nodemon.json Configuration

flowchart TD
    A[Start Nodemon with nodemon.json] --> B[Watch files/directories]
    B -->|Changes detected in watched .ts files| C{Is file ignored?}
    C -- Yes --> D[Ignore change, no restart]
    C -- No --> E[Run exec command]
    E --> F["yarn build"]
    F --> G["node dist/avalanche/api/src/app.js"]
    G --> B

Summary

The `nodemon.json` file is a succinct yet powerful configuration tailored to streamline the development process for a TypeScript Node.js application. It orchestrates file watching, build execution, and application restart automatically, ensuring developers experience minimal friction when updating source code. By selectively ignoring and watching files, it optimizes restart triggers, preventing unnecessary downtime and promoting efficient development cycles.