-
Notifications
You must be signed in to change notification settings - Fork 37
CLI
Mauro Gadaleta edited this page May 5, 2026
·
4 revisions
node-dependency-injection ships with a command-line interface that helps you create and validate configuration files, and inspect service definitions.
After installing the package, the ndi binary is available:
npx ndi --helpCreates an empty configuration file in the given directory.
ndi config:create [options] <path>Options
| Option | Default | Description |
|---|---|---|
-n, --name <name> |
services |
Name of the output file (without extension) |
-f, --format <format> |
yaml |
Format of the output file (yaml, json, js) |
Examples
# Create services.yaml in the current directory
ndi config:create .
# Create a JSON file named container in src/
ndi config:create --name=container --format=json src/
# Create a JS file
ndi config:create --format=js ./configValidates a configuration file and reports any errors. Supports .yaml, .json and .js formats — the format is detected automatically from the file extension.
ndi config:check <path>Examples
# Check a YAML configuration file
ndi config:check ./config/services.yaml
# Check a JSON configuration file
ndi config:check ./config/services.json
# Check a JS configuration file
ndi config:check ./config/services.jsOn success the command exits with code 0. On failure it prints the error message and exits with code 1.
Displays detailed information about a specific service registered in a configuration file.
ndi container:service <path> <service>Arguments
| Argument | Description |
|---|---|
path |
Path to the configuration file (YAML, JSON or JS) |
service |
Service ID to inspect |
Example
ndi container:service ./config/services.yaml app.mailerThe output is a table showing:
- Key — the service ID
- Class Name — the class used to instantiate the service
- Arguments — constructor arguments and their types/IDs
- Public — whether the service is publicly accessible
- Calls — configured method calls (setter injection)
- Tags — tags attached to the service
- Properties — injected properties
- Laziness — whether the service is lazy
Copyright © 2023-2024 Mauro Gadaleta