I've encountered an issue with my mono repo project that contains two packages built using Lerna: Base
and Libs
. I'm attempting to utilize TypeDi dependency injection, but the classes marked with the Service()
decorator from the Libs
package are not being created in the Base
Container:
libs/example.js
import { Service } from 'typedi';
@Service()
export class ExampleService{
//...do stuff
}
libs/index.js
import { ExampleService } from './example';
export { ExampleService };
base/index.js
import { Container } from 'typedi';
import { ExampleService } from 'Libs'
//Error thrown here "Service with "MaybeConstructable<ExampleService>" identifier was not found in the container. Register it before usage via explicitly calling the "Container.set" function or using the "@Service()" decorator."
const xmpl = Container.get(ExampleService)
Is there any way to inject these classes without explicitly importing all the class dependencies into the Base
project and using Container.set()