nodemon.json


Overview

The [nodemon.json](/projects/291/68849) file is a configuration file used by **Nodemon**, a utility that monitors for any changes in your source code and automatically restarts your Node.js application. This particular configuration governs how Nodemon watches files, which files to ignore, which file extensions to monitor, and what command to execute upon changes.

In this project, the [nodemon.json](/projects/291/68849) file is tailored for a TypeScript-based Node.js application. It ensures that the application rebuilds using `yarn build` before restarting the server whenever relevant files change. This automation streamlines the development workflow by reducing manual steps and helping maintain up-to-date builds during development.


Detailed Explanation of Configuration Properties

This JSON file does not contain classes or functions but consists of key-value pairs defining Nodemon behavior.

Property

Type

Description

Example / Notes

`ignore`

Array of strings

Specifies files or directories that Nodemon should **not** watch for changes. Useful for ignoring files that do not affect the running app or would trigger unnecessary restarts.

[["src/routes.ts"]](/projects/291/69202) - Changes to this file will be ignored by Nodemon.

watch

Array of strings

Defines files or directories that Nodemon **should** watch for changes. When these files change, Nodemon triggers the specified command. This is useful to explicitly monitor build artifacts or source code.

[["../../../packages/*/dist/tsconfig.tsbuildinfo", "../../common/api/dist/tsconfig.tsbuildinfo", "src"]](/projects/291/68809) watches specific build info files and the `src` directory.

ext

String

Specifies the file extensions Nodemon should monitor. This restricts watching to files with these extensions.

`"ts"` means only TypeScript files trigger restarts.

exec

String

The command Nodemon executes when a watched file changes. This typically rebuilds the project and runs the application.

["yarn build && node dist/bnbsmartchain/api/src/app.js"](/projects/291/68852) runs the build script and then starts the Node.js app at the compiled location.


Usage Example

When running Nodemon with this configuration (either by placing this [nodemon.json](/projects/291/68849) in the root directory or specifying it with the [-c](/projects/291/68956) option), the development workflow is as follows:

  1. Nodemon watches for changes in:

    • All TypeScript files under src

    • Specific build info files generated by TypeScript incremental compilation in relative package directories

  2. Changes to src/routes.ts are ignored to prevent unnecessary restarts.

  3. When a relevant file changes:

    • Nodemon runs yarn build to compile TypeScript to JavaScript.

    • After a successful build, Nodemon runs the Node.js application located at dist/bnbsmartchain/api/src/app.js.

  4. The application restarts automatically with the latest code.

This setup is especially helpful in monorepo or multi-package projects where incremental builds are monitored via [tsconfig.tsbuildinfo](/projects/291/68809) files.


Important Implementation Details


Interaction with Other System Components


Mermaid Diagram: Workflow of nodemon.json Configuration

This flowchart illustrates the event-driven workflow Nodemon follows based on this configuration:

flowchart TD
    A[Start Nodemon] --> B[Watch .ts files in src + tsbuildinfo files]
    B --> C{File Changed?}
    C -- No --> B
    C -- Yes --> D{Is Changed File in ignore list?}
    D -- Yes --> B
    D -- No --> E[Run "yarn build"]
    E --> F{Build Successful?}
    F -- No --> B
    F -- Yes --> G[Run "node dist/bnbsmartchain/api/src/app.js"]
    G --> B

Summary

[nodemon.json](/projects/291/68849) configures Nodemon to enhance the development experience by:

This file is a critical piece in the automated development loop, ensuring that changes are swiftly compiled and reflected in the running application without manual intervention.