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.