You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/faq/errors.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
## Common errors
1
+
###Common errors
2
2
3
3
During your development with NestJS, you may encounter various errors as you learn the framework.
4
4
5
-
### "Cannot resolve dependency" error
5
+
####"Cannot resolve dependency" error
6
6
7
7
Probably the most common error message is about Nest not being able to resolve dependencies of a provider. The error message usually looks something like this:
8
8
@@ -29,9 +29,7 @@ If the `<unknown_token>` above is the string `Object`, it means that you're inje
29
29
30
30
Also, make sure you didn't end up injecting the provider on itself because self-injections are not allowed on NetJS. When this happens, `<unknown_token>` will likely be equal to `<provider>`.
31
31
32
-
#### Error on monorepos
33
-
34
-
If you are in a monorepo setup, you may face the same error as above but for core provider called `ModuleRef` as a `<unknown_token>`:
32
+
If you are in a **monorepo setup**, you may face the same error as above but for core provider called `ModuleRef` as a `<unknown_token>`:
35
33
36
34
```bash
37
35
Nest can't resolve dependencies of the <provider> (?).
@@ -59,7 +57,7 @@ Solutions:
59
57
60
58
- For **Yarn** Workspaces, use the [nohoist feature](https://classic.yarnpkg.com/blog/2018/02/15/nohoist) to prevent hosting the package `@nestjs/core`.
61
59
62
-
### "Circular dependency" error
60
+
#### "Circular dependency" error
63
61
64
62
Occasionally you'll find it difficult to avoid [circular dependencies](https://docs.nestjs.com/fundamentals/circular-dependency) in your application. You'll need to take some steps to help Nest resolve these. Errors that arise from circular dependencies look like this:
65
63
@@ -77,7 +75,7 @@ Scope [<module_import_chain>]
77
75
78
76
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`.
79
77
80
-
### Debugging dependency errors
78
+
#### Debugging dependency errors
81
79
82
80
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.
0 commit comments