-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: Using typedi with monorepo #942
Comments
I’m using typedi in an nx monorepo without issues. Could you please create a simple reproduction repo on github so we can investigate? |
Of course, created a public repo, you can start it up with 2 make commands from readme file. If you go to service2/src/services/Authentication.ts you will see that I try to reach Cryptography service. If I use Cryptography service defined in the same project (in the same folder in this case as well) - it works as it should, however if I use that CryptographyService from service1 - it does not... |
It seems to me that the node_modules resolution is a bit interesting in your repo. Because you have a node_modules folder for each app, the Service decorator gets resolved from their respective folders, resulting in multiple instances of Container. |
I was trying to...
I was trying to use typedi with monorepo, where we have a common repo where we place some common stuff between other repos, so there are common services there as well.
The problem:
If I create service in that common repo, decorate it with @service decorator, I still can't inject it anywhere else, it throws ServiceNotFoundError. If I place the same services inside my repo I'm trying to access this service in - everything works just fine. However now I need to duplicate all these services in all repos which is not optimal... Is there are way to share these services between repos in monorepo structure? Any ideas would really be helpful
The text was updated successfully, but these errors were encountered: