#how am I supposed to handle a single module converting to an ES Module

8 messages · Page 1 of 1 (latest)

lethal gull
#

const { Strategy: RedditStrategy } = await import('passport-reddit');

Instead change the require of index.js in /home/skeddles/lospec-website/app.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/skeddles/lospec-website/app.js:327:22)
    at Object.<anonymous> (/home/skeddles/lospec-website/server.js:2:13) {```

So I'm supposed to use a dynamic import. Aka `import()`. Which returns a promise. So it needs to be awaited. Which it can't because it's required on the top level.

So what am I supposed to do?
wind brook
#

don't put it at the top level

#

or just use esm

#

or use a previous maintained version that still supports cjs, if such a version exists

lethal gull
#

what do you mean dont use esm?

wind brook
#

when did i say dont use esm

#

i gave 3 solutions, either [move it to not the top level], [use esm], or [use a maintained cjs-compatible version]

lethal gull
#

sorry, misread.

unfortunately i think i have to go with option 3 (except its not maintained)