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.

Compile step failing with "require() of ES Modules not supported" error [Svelte Kit]

See original GitHub issue

I believe I followed the setup steps to the letter, but I’m hoping this issue is something straightforward that I’m missing.

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: <PATH>/houdini.config.js
require() of ES modules is not supported.
require() of <PATH>/houdini.config.js from <PATH>/node_modules/houdini-common/build/cjs/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename houdini.config.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from <PATH>/package.json.

FYI, If I remove the “type”:“module” line from package.json it errors out with Cannot use import statement outside a module related to the line in houdini.config: import path from 'path'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AlecAivaziscommented, May 17, 2021

@thormuller - thanks for bringing the issue to my attention so quickly!

@pixelmund i think you’re right, however I would like to verify that the current version of @kit supports sapper before we do that just so to avoid any issues we can see coming.

I’m currently running into a nasty hurdle in the integration - jest doesn’t seem to allow the use of import.meta.url so i’m going to have to figure out some workaround for the test suite before #69 can go in.

1reaction
thormullercommented, May 17, 2021

I can also confirm that this fixes the error on compile. Thanks all! Looking forward to making a success of Houdini–it’s great to see a Svelte-native Graphql client.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >
Sveltekit + Windows = ERR_REQUIRE_ESM #10 - GitHub
Using this library with SvelteKit 1.0.0-next.115 on Windows gives the following error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ...
Read more >
Node 13 must use import to load es module - Seba Online
To include the File System module, use the require () method: var fs = require ... разумом. js require() of ES modules is...
Read more >
rollup.js
To make sure your ES modules are immediately usable by tools that work with CommonJS such as Node.js and webpack, you can use...
Read more >
Docs • Svelte
Complete documentation for Svelte.
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