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

Original error stack trace: Error [ERR_REQUIRE_ESM]: require() of ES Module #3062

Closed
xplosionmind opened this issue Oct 6, 2023 · 3 comments
Labels
duplicate feature: esm Related to supporting ES Modules (in parallel to CommonJS)

Comments

@xplosionmind
Copy link

Operating system

Fedora 38

Eleventy

2.0.1

Describe the bug

I do not really know what is happening, so I will just share the build debug log

Reproduction steps

Run ELEVENTY_ENV=development eleventy --serve --watch --incremental

Expected behavior

Build should not fail

Reproduction URL

No response

Screenshots

No response

@dagnelies
Copy link

dagnelies commented Oct 20, 2023

Similar problem here. Adding a .eleventy.js config makes the build fail. I guess there is an issue between "require" and "modules"

> npx @11ty/eleventy
[11ty] Eleventy CLI Fatal Error: (more in DEBUG output)
[11ty] 1. Error in your Eleventy config file '.eleventy.js'. (via EleventyConfigError)
[11ty] 2. require() of ES Module /workspaces/app/.eleventy.js from /workspaces/app/node_modules/@11ty/eleventy/src/Util/Require.js not supported.
[11ty] Instead change the require of .eleventy.js in /workspaces/app/node_modules/@11ty/eleventy/src/Util/Require.js to a dynamic import() which is available in all CommonJS modules. (via Error)
[11ty] 
[11ty] Original error stack trace: Error [ERR_REQUIRE_ESM]: require() of ES Module /workspaces/app/.eleventy.js from /workspaces/app/node_modules/@11ty/eleventy/src/Util/Require.js not supported.
[11ty] Instead change the require of .eleventy.js in /workspaces/app/node_modules/@11ty/eleventy/src/Util/Require.js to a dynamic import() which is available in all CommonJS modules.
[11ty]     at requireLocal (/workspaces/app/node_modules/@11ty/eleventy/src/Util/Require.js:6:10)
[11ty]     at TemplateConfig.requireLocalConfigFile (/workspaces/app/node_modules/@11ty/eleventy/src/TemplateConfig.js:287:23)
[11ty]     at TemplateConfig.mergeConfig (/workspaces/app/node_modules/@11ty/eleventy/src/TemplateConfig.js:334:28)
[11ty]     at TemplateConfig.getConfig (/workspaces/app/node_modules/@11ty/eleventy/src/TemplateConfig.js:159:26)
[11ty]     at new Eleventy (/workspaces/app/node_modules/@11ty/eleventy/src/Eleventy.js:109:39)
[11ty]     at Object.<anonymous> (/workspaces/app/node_modules/@11ty/eleventy/cmd.js:60:16)

(Using Node v19.9.0 & eleventy v2.0.1)

@dagnelies
Copy link

Ok, I figured it out, the error happens when the package.json has "type": "module".

@zachleat
Copy link
Member

zachleat commented Nov 3, 2023

Duplicate of #836, which has been fixed for 3.0.

@zachleat zachleat added feature: esm Related to supporting ES Modules (in parallel to CommonJS) and removed needs-triage labels Nov 3, 2023
@zachleat zachleat added this to the Eleventy 3.0.0 milestone Nov 3, 2023
@zachleat zachleat closed this as completed Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate feature: esm Related to supporting ES Modules (in parallel to CommonJS)
Projects
None yet
Development

No branches or pull requests

3 participants