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

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'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@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.

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.

@AlecAivazis Tested and can confirm it works!

I pulled down your repo and reproduced the error so we know its not a problem with node, i’m going to see if I can figure out what’s different between your setup and the example