Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: require() of ES Module - Instead change the require of index.js in applicationMutation.ts to a dynamic import() which is available in all CommonJS modules. #25

Closed
alan345 opened this issue Jun 17, 2023 · 8 comments

Comments

@alan345
Copy link

alan345 commented Jun 17, 2023

Hello,

When in the backend (Express) with Typescript,
I do this

npm install @passwordless-id/webauthn

then:

import { server } from '@passwordless-id/webauthn'
const applicationMutation = {
  createPasskeyApplication: async (_parent: unknown, args: Args, ctx: Ctx): Promise<Application> => {
     const registrationParsed = await server.verifyRegistration(args, expected)
  }
}

When I compile, I have this error:

[ERROR] 18:29:27 Error: require() of ES Module /Users/alan/Documents/app/backend/server/graphql/node_modules/@passwordless-id/webauthn/dist/esm/index.js from /Users/alan/Documents/app/backend/server/graphql/src/resolvers/mutation/applicationMutation.ts not supported.
Instead change the require of index.js in /Users/alan/Documents/app/backend/server/graphql/src/resolvers/mutation/applicationMutation.ts to a dynamic import() which is available in all CommonJS modules.
(node:22269) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

Any idea where this issue might come from?
Thanks fro your help!

@alan345 alan345 changed the title Error: require() of ES Module Error: require() of ES Module - Instead change the require of index.js in applicationMutation.ts to a dynamic import() which is available in all CommonJS modules. Jun 17, 2023
@dagnelies
Copy link
Collaborator

Too old target or node version perhaps?

@dagnelies
Copy link
Collaborator

dagnelies commented Jun 29, 2023

Closed due to inactivity / insufficient information. You are welcome to re-open it with more details.

@rogue-kitten
Copy link

getting this same error in nestJS as well. @alan345 did you figure this out?

@dagnelies
Copy link
Collaborator

@rogue-kitten What's your node version?

@rogue-kitten
Copy link

it's the latest one, 20.7.0

@neerosity
Copy link

neerosity commented Oct 25, 2023

facing same issue I have node v 20+ #35

@enri90
Copy link

enri90 commented Jan 7, 2024

Is it possible to use the build module in CommonJS?

@dagnelies
Copy link
Collaborator

See also #35 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants