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

Fixing main refer to module #223

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fixing main refer to module #223

wants to merge 1 commit into from

Conversation

r4nd0wn
Copy link

@r4nd0wn r4nd0wn commented Jul 9, 2023

If main refers to the modules, it issues some Errors when using require.
The following Error is fixed with the PR:

node:internal/modules/cjs/loader:1111
    throw new ERR_REQUIRE_ESM(filename, true);
    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/datebook/dist/datebook.min.mjs not supported.
Instead change the require of /app/node_modules/datebook/dist/datebook.min.mjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/app/calendarGen/calGenerator.js:5:20)
    at Object.<anonymous> (/app/index.js:4:24) {
  code: 'ERR_REQUIRE_ESM'
}

One common example of using require instead of import is when using typescript with es6 as target.

If main refers to the modules, it issues some Errors when using require. The following Error is fixed with it:
```sh
node:internal/modules/cjs/loader:1111
    throw new ERR_REQUIRE_ESM(filename, true);
    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/datebook/dist/datebook.min.mjs not supported.
Instead change the require of /app/node_modules/datebook/dist/datebook.min.mjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/app/calendarGen/calGenerator.js:5:20)
    at Object.<anonymous> (/app/index.js:4:24) {
  code: 'ERR_REQUIRE_ESM'
}
```
This occurs when using es6 as ts target.
@millansingh
Copy link

Yes please merge this. We had to patch-package this cause it's broken in NodeJS with es6.

@HampusDunstromBambuser
Copy link

We're also encountering this issue, please merge this fix!

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

Successfully merging this pull request may close these issues.

3 participants