Compile step failing with "require() of ES Modules not supported" error [Svelte Kit]
See original GitHub issueI 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:
- Created 2 years ago
- Comments:15 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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 ofimport.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.