question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feature: add support for ES modules

See original GitHub issue

TypeDI is incompatible with Node 13 and 14 when using ES6 Modules (e.g. in Node 14 you activate it with "type": "module" in your package.json).

I receive the following error:

api    | import { Service } from 'typedi';
api    |          ^^^^^^^
api    | SyntaxError: The requested module 'typedi' does not provide an export named 'Service'
api    |     at ModuleJob._instantiate (internal/modules/esm/module_job.js:92:21)
api    |     at async ModuleJob.run (internal/modules/esm/module_job.js:107:20)
api    |     at async Loader.import (internal/modules/esm/loader.js:179:24)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
MichalLytekcommented, Jul 30, 2020

@desmap TypeGraphQL is not a part of the typestack. The only TypeGraphQL requirement for DI lib is the .get() method of container, so it works with every other DI lib in Node.js. TypeDI is mentioned in docs/examples only because of it’s simplicity, like Apollo Server is even as it’s super slow TBH (https://github.com/benawad/node-graphql-benchmarks#benchmarks) 😉 For production apps I would use https://github.com/microsoft/tsyringe.

1reaction
NoNameProvidedcommented, Aug 8, 2020

This has been added in 45b0974a2a4d563811b43887a49433aed35f2aee. It will be released in the next version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using ES modules in Node.js - LogRocket Blog
Modules are independent building blocks of a software program. They are basically a design pattern that implements features of modular ...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
Node.js fully supports ECMAScript modules as they are currently specified and provides interoperability between them and its original module format, CommonJS.
Read more >
ES modules: A cartoon deep-dive - Mozilla Hacks - the Web ...
ESM (EcmaScript modules) is a newer system which has been added to the JavaScript specification. Browsers already support ES modules, and Node ...
Read more >
Announcing core Node.js support for ECMAScript modules
However, now that Node.js supports both CommonJS and ES modules, it is best to be ... An experimental feature, conditional exports, would add...
Read more >
Using Node.js ES modules and top-level await in AWS Lambda
It provides customers the benefits of ES module features like import/export operators, language-level support for modules, strict mode by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found