79494258

Date: 2025-03-08 10:54:58
Score: 1.5
Natty:
Report link

From the docs:

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>:

Nest can't resolve dependencies of the <provider> (?). Please make
sure that the argument ModuleRef at index [<index>] is available in
the <module> context. ...

This likely happens when your project end up loading two Node modules of the package @nestjs/core.

That was the case for me.

$ npm ls @nestjs/core
[email protected] /Users/dolan/IdeaProjects/papertrace/code
└─┬ [email protected] -> ./server
  ├── @nestjs/[email protected]
  ├─┬ @nestjs/[email protected]
  │ └── @nestjs/[email protected] deduped
  ├─┬ @nestjs/[email protected]
  │ └─┬ @nestjs/[email protected]
  │   └─┬ @nestjs/[email protected]
  │     └── @nestjs/[email protected] deduped
  ├─┬ @nestjs/[email protected]
  │ └── @nestjs/[email protected] deduped
  └─┬ @nestjs/[email protected]
    └── @nestjs/[email protected] deduped

Notice @nestjs/typeorm still depends on NestJS 9 (and I forgot to update Swagger as well).

npm upgrade did the job.

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): face the same error
  • Low reputation (0.5):
Posted by: ILikeFood