nodemon.json

Overview

The `nodemon.json` file is a configuration file used by **Nodemon**, a utility that monitors changes in source files and automatically restarts the Node.js application during development. This file specifies how Nodemon should behave for the particular project, defining which files or directories to watch or ignore, the file extensions that trigger restarts, and the command to execute when changes are detected.

This configuration optimizes the development workflow by ensuring that the application rebuilds and restarts only when relevant source files change, improving efficiency and reducing unnecessary restarts.


Configuration Properties

The file is a JSON object with the following properties:

Property

Type

Description

`ignore`

Array of strings

Specifies file(s) or directory paths that Nodemon should ignore and not watch for changes.

`watch`

Array of strings

Specifies file(s) or directory paths that Nodemon should watch for changes.

`ext`

String

Specifies the file extensions that Nodemon should monitor for changes.

`exec`

String

The command to execute when a watched file changes.


Detailed Explanation of Properties

ignore

watch

ext

exec


Usage Example

When running Nodemon with this configuration, the developer would typically execute:

nodemon

Nodemon will:

  1. Watch all .ts files inside the src directory and the specified build info files.

  2. Ignore changes in src/routes.ts.

  3. On relevant changes, run yarn build to compile the project.

  4. Start or restart the Node.js server by running the compiled app at dist/ethereum/api/src/app.js.

This setup is particularly useful in a TypeScript monorepo or multi-package workspace, where build artifacts and incremental builds are important to track.


Implementation Details and Notes


Interaction with the System


Mermaid Diagram

The diagram below illustrates the workflow of this `nodemon.json` configuration during development:

flowchart TD
    A[File Change Detected] --> B{Is file ignored?}
    B -- Yes --> C[No Restart]
    B -- No --> D{Is file extension '.ts'?}
    D -- No --> C
    D -- Yes --> E{Is file in watch list?}
    E -- No --> C
    E -- Yes --> F[Run "yarn build"]
    F --> G{Build successful?}
    G -- No --> H[Do not restart app]
    G -- Yes --> I[Run "node dist/ethereum/api/src/app.js"]
    I --> J[App Restarted]

Summary


If you want to customize the behavior, you can adjust the paths in `watch` and `ignore`, change the file extensions in `ext`, or modify the `exec` command to fit your build and launch scripts.