#If ModuleRef is a provider, is it part of the current EventEmitter? & other nestjs/core error

1 messages · Page 1 of 1 (latest)

ocean galleon
#

Hey everyone, I've been dealing with these issues in my turborepo using pnpm as the package manager, when exporting nestjs modules from local packages.

The first issue was in relation to a module that I exported to my microservices, that initalized the EventEmitterModule with options that should be shared among the microservices, among more things. This gave an error of

Nest can't resolve dependencies of the EventSubscribersLoader .... Please make sure that the argument ModuleRef at index [4] is available in the EventEmitterModule context.

Potential solutions:
- If ModuleRef is a provider, is it part of the current EventEmitterModule?
...

And after some research, it turned out that a solution was to set the @dim citrus/core package as peerDependancy (more info here: https://docs.nestjs.com/faq/common-errors)

#

So that above issue was indeed fixed

The issue now however, is that when I import a shared logger module/service from my package to one of my nest microservices, this error is sometimes thrown when I start my service:

@../template-service:dev: TypeError: Cannot read properties of undefined (reading 'setContext')
@../template-service:dev:     at new ActionProxyService (C:\Users\Dareon\development\..\node_modules\.pnpm\file+packages+services+shared+action-service-shared_@nestjs+core@9.4.0\node_modules\@rewards\action-service-shared\src\action\modules\action-proxy\action-proxy.service.ts:24:17)
@../template-service:dev:     at Injector.instantiateClass (C:\Users\Dareon\development\rewards\node_modules\.pnpm\@nestjs+core@9.4.0_yn6wkbpy63w25j7vqpaxxesoiu\node_modules\@nestjs\core\injector\injector.js:351:19)

It also seems to be related to @dim citrus/core, which is weird, because the package doesn't even use nestjs/core. It's a really simple package that exports a logger that both other packages that have nest modules use, as well as the microservices.

When it does start happening, I have to delete all node modules and the pnpm-lock file, and reinstall/rebuild everything. Incredibly annoying.

Does anyone know why this might be happening?