aws-samples / amazon-cognito-passwordless-auth

Passwordless authentication with Amazon Cognito: FIDO2 (WebAuthn, support for Passkeys), Magic Link, SMS OTP Step Up
Apache License 2.0
382 stars 69 forks source link

[Need Help] - No "exports" main defined in ../node_modules/amazon-cognito-passwordless-auth/package.json #185

Closed kc3981 closed 1 month ago

kc3981 commented 3 months ago

Thank you ottokruse for creating this very useful library.

I'm integrating this with a React web-app and using Amplify to manage user integration.

When I run the app I'm getting the error No "exports" main defined in ../node_modules/amazon-cognito-passwordless-auth/package.json

Here is the tsconfig.json of the project.

{
  "compilerOptions": {
    "jsx": "react",
    "target": "es6",
    "module": "esnext",
    "lib": [
      "es5",
      "es6",
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "baseUrl": "./src",
    "sourceMap": true,
    "allowJs": true,
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "strict": false,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "strictPropertyInitialization": false,
    "moduleResolution": "node",
    "isolatedModules": true,
    "noImplicitAny": true,
    "noImplicitThis": true,
    "strictNullChecks": false,
    "noStrictGenericChecks": true,
    "ignoreDeprecations": "5.0",
    "paths": {
      "@pages/*": ["./pages/*"],
      "@context/*": ["./core/context/*"],
      "@helpers/*": ["./core/helpers/*"],
      "@service/*": ["./core/service/*"],
      "@core/*": ["./core/*"],
      "@forms/*": ["./components/forms/*"],
      "@shared-components/*": ["./components/shared/*"],
    },
    "noEmit": true
  },
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest",
    "razzle.config.js"
  ],
  "include": [
    "src"
  ]

}

Node version: 20.x I'm unable to spot the bug in my code/config. Any help would be much appreciated.

Thanks a ton in advance.

ottokruse commented 3 months ago

Hi mate. How are you importing the library? Can you paste the import statement you're using that fails?

kc3981 commented 2 months ago

My apologies for dropping the thread. Was pulled into another feature :)

this is the import statement

import { Passwordless } from 'amazon-cognito-passwordless-auth';

When I use this statement in a Hello World React app it works just fine. When I integrate it into the production app it throws this error.

I'm unable to pin-point the configuration that is causing this.

ottokruse commented 1 month ago

You may need to upgrade Node.js or babel to fix this.

We have too little info to help you otherwise. Haven't seen this issue before so don't know a quick fix