Skip to content

Error ERR_REQUIRE_ESM when using the StellarWalletsKit in SvelteKit #46

@ElliotFriend

Description

@ElliotFriend
  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

I've created a vanilla SvelteKit app, using npx sv create my-app, selecting the most barebones options, using TypeScript.

I import the wallet kit components just like in the documentation:

import { StellarWalletsKit, WalletNetwork, allowAllModules, XBULL_ID } from "@creit.tech/stellar-wallets-kit";

And that's enough to throw an error. I'm experiencing the exact same trouble as reported in #11 where I see an error about ES modules and commonjs.

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/elliotvoris/Dev/experiments/my-app2/node_modules/lit/index.js from /Users/elliotvoris/Dev/experiments/my-app2/node_modules/@creit.tech/stellar-wallets-kit/components/modal/stellar-wallets-modal.cjs not supported.
Instead change the require of index.js in /Users/elliotvoris/Dev/experiments/my-app2/node_modules/@creit.tech/stellar-wallets-kit/components/modal/stellar-wallets-modal.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/elliotvoris/Dev/experiments/my-app2/node_modules/@creit.tech/stellar-wallets-kit/components/modal/stellar-wallets-modal.cjs:1:20) {
  code: 'ERR_REQUIRE_ESM'
}
  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

SvelteKit uses vite under the hood, so perhaps the problem is with that? I don't know nearly enough about the specifics that go into packaging, building, etc. So, I'm a bit at a loss.

Creating a brand new React app gave me no such errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions