'Calling A Function from the main.ts file to other ts file is not working in Node js

I have a project in Node JS with the following structure:

  • ormconfig.js
  • package.json
  • src
    • main.ts
    • user
      • user.module.ts
      • user.entity.ts
      • user.service.ts (include a function "this.reposiroty.find(...)")
    • mailer
      • mailer.module.ts
      • mailer.service.ts
      • mailer.listener.ts ("the problem is here")

"main.ts" calls a function in "mailer.listener.ts", then "mailer.listener.ts" calls in its turn the function FindAlltoAlert in "user.service.ts", accordingly, an error printed to the console (Error: Cannot read property 'find' of undefined), which is generated when "mailer.listener.ts" calls function FindAlltoAlert in "user.service.ts".

Please advise!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source