Skip to content

getting an ESM error when trying to use the library... #4

@rchrdnsh

Description

@rchrdnsh

getting the following error in the terminal when trying to use the library:

[vite] Error when evaluating SSR module /Users/rchrdnsh/Code/Svelte/RYKR-kit/src/routes/stripe.svelte:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/svelte-stripe-js/index.js
require() of ES modules is not supported.
require() of /Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/svelte-stripe-js/index.js from /Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/vite/dist/node/chunks/dep-c1a9de64.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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/svelte-stripe-js/package.json.

    at new NodeError (node:internal/errors:363:5)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1126:13)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at Module.require (node:internal/modules/cjs/loader:1013:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at nodeRequire (/Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73479:17)
    at ssrImport (/Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73431:20)
    at eval (/Users/rchrdnsh/Code/Svelte/RYKR-kit/src/routes/stripe.svelte:12:31)
    at instantiateModule (/Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73464:166)
Must use import to load ES Module: /Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/svelte-stripe-js/index.js
require() of ES modules is not supported.
require() of /Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/svelte-stripe-js/index.js from /Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/vite/dist/node/chunks/dep-c1a9de64.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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/rchrdnsh/Code/Svelte/RYKR-kit/node_modules/svelte-stripe-js/package.json.

...dunno if there is something that I need to do differently, as I have really only copied and pasted your code example so far...

I'm on the latest version of sveltekit, which at this moment is 144...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions