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
361 stars 62 forks source link

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

Open kc3981 opened 1 month ago

kc3981 commented 1 month 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 1 month ago

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

kc3981 commented 5 days 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.