Skip to content

Commit 5e3b9be

Browse files
committed
feat: add docs about NEST_DEBUG
1 parent ff47ece commit 5e3b9be

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

content/faq/errors.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ Scope [<module_import_chain>]
4141
```
4242

4343
Circular dependencies can arise from both providers depending on each other, or typescript files depending on each other for constants, such as exporting constants from a module file and importing them in a service file. In the latter case, it is advised to create a separate file for your constants. In the former case, please follow the guide on circular dependencies and make sure that both the modules **and** the providers are marked with `forwardRef`.
44+
45+
#### Debugging Dependency Errors
46+
47+
Along with just manually verifying your dependencies are correct, as of Nest 8.1.0 you can set the `NEST_DEBUG` environment variable to a string that resolves as truthy, and get extra logging information while Nest is resolving all of the dependencies for the application.
48+
49+
<figure><img src="/assets/injector_logs.png" /></figure>
50+
51+
In the above image, the string in yellow is the host class of the dependency being injected, the string in blue is the name of the injected dependency, or its injection token, and the string in purple is the module in which the dependency is being searched for. Using this, you can usually trace back the dependency resolution for what's happening and why you're getting dependency injection problems.

content/fundamentals/dependency-injection.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ What happens when your requirements go beyond those offered by _Standard provide
137137

138138
Nest allows you to define Custom providers to handle these cases. It provides several ways to define custom providers. Let's walk through them.
139139

140+
> info **Hint** If you are having problems with dependency resolution you can set the `NEST_DEBUG` environment variable and get extra dependency resolution logs during startup.
141+
140142
#### Value providers: `useValue`
141143

142144
The `useValue` syntax is useful for injecting a constant value, putting an external library into the Nest container, or replacing a real implementation with a mock object. Let's say you'd like to force Nest to use a mock `CatsService` for testing purposes.

src/assets/injector_logs.png

151 KB
Loading

0 commit comments

Comments
 (0)