Skip to content

Error on Services registration -> require(...).default is not a constructor #3862

Answered by RomainLanz
lukfor85 asked this question in Help
Discussion options

You must be logged in to vote

Hey @lukfor85 ! 👋🏻

I am not sure what you are trying to do.
You should use providers only to register third-party packages or part of your application you want to externalize (in a package). The thing you bind should have no relation with your application code (or anything loaded by the IOC).

Here, you are binding internal services for no reason.

If your goal is to create a singleton of your service, you can simply export an instance of your class inside your module.

class MySingleton {}

const instance = new MySingleton()
export default instance

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@lukfor85
Comment options

Comment options

You must be logged in to vote
2 replies
@thetutlage
Comment options

@lukfor85
Comment options

Answer selected by lukfor85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants