Skip to content
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

Encountering errors while using library inside NodeJS + TS project #376

Closed
ivkoandrv opened this issue Jan 9, 2024 · 4 comments
Closed

Comments

@ivkoandrv
Copy link

I've encountered following error:

require() of ES Module *project_path*/node/node_modules/@extractus/article-extractor/src/main.js from *controller_name* not supported.\nInstead change the require of main.js in *controller-name* to a dynamic import() which is available in all CommonJS modules.

I've tried connecting this thing in various ways:

  1. As in doc: import {extract} from "@extractus/article-extractor"
  2. Dynamic import: const ArticleExtract = await import("@extractus/article-extractor")

But, when I try it on the same, but the JS project - it works (I've use 1st method)

Node: 20

TS Config:
image

Help me, please, it's quite important

@ndaidong
Copy link
Collaborator

@ivkoandrv there is an example that works with Node.js / Typescript. I found that the most difference is module in TS config file. Could you try to change from "commonjs" to "es6"?

@ivkoandrv
Copy link
Author

@ndaidong Yep, I've tried it. Maybe it's stuck with tsconfig at all.

image

Thank's you

@ndaidong
Copy link
Collaborator

@ivkoandrv please try to run the example in your own environment to see if it works as expected. Then replace your project tsconfig file with the example config to verify if it's really the cause.

@ivkoandrv
Copy link
Author

@ndaidong Yeah, example works perfect. I'll change my configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants