amplify-js: Error importing Auth after upgrading NX 16 and RN 0.72.3

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

  System:
    OS: macOS 13.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 37.30 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.12.1/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
    Watchman: 2023.08.14.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 115.0.5790.170
    Safari: 16.6
  npmPackages:
    @babel/core: 7.20.12 => 7.20.12 (7.22.10)
    @babel/plugin-proposal-class-properties: 7.14.5 => 7.14.5 (7.18.6)
    @babel/plugin-proposal-nullish-coalescing-operator: 7.16.7 => 7.16.7 (7.18.6)
    @babel/plugin-proposal-optional-chaining: 7.16.7 => 7.16.7 (7.21.0)
    @babel/plugin-transform-arrow-functions: 7.16.7 => 7.16.7 (7.22.5)
    @babel/plugin-transform-shorthand-properties: 7.0.0 => 7.0.0 (7.22.5)
    @babel/plugin-transform-template-literals: 7.16.7 => 7.16.7 (7.22.5)
    @babel/preset-env: ^7.20.0 => 7.22.10 
    @babel/preset-flow: 7.18.6 => 7.18.6 (7.22.5)
    @babel/preset-react: 7.18.6 => 7.18.6 (7.22.5)
    @babel/preset-typescript: 7.16.7 => 7.16.7 (7.22.5)
    @babel/runtime: 7.22.10 => 7.22.10 
    @capacitor/core: 2.4.3 => 2.4.3 
    @cypress/angular:  0.0.0-development 
    @cypress/mount-utils:  0.0.0-development 
    @cypress/react:  0.0.0-development 
    @cypress/react18:  0.0.0-development 
    @cypress/svelte:  0.0.0-development 
    @cypress/vue:  0.0.0-development 
    @cypress/vue2:  0.0.0-development 
    @datadog/browser-logs: 3.10.1 => 3.10.1 
    @datadog/mobile-react-native: 1.1.4 => 1.1.4 
    @dnd-kit/core: 6.0.8 => 6.0.8 
    @dnd-kit/sortable: 7.0.2 => 7.0.2 
    @dnd-kit/utilities: 3.2.1 => 3.2.1 
    @emotion/babel-plugin: 11.10.5 => 11.10.5 (11.11.0)
    @emotion/react: 11.11.1 => 11.11.1 
    @emotion/styled: 11.11.0 => 11.11.0 
    @fullcalendar/core: 5.6.0 => 5.6.0 
    @fullcalendar/daygrid: 5.6.0 => 5.6.0 
    @fullcalendar/interaction: 5.6.0 => 5.6.0 
    @fullcalendar/list: 5.6.0 => 5.6.0 
    @fullcalendar/react: 5.6.0 => 5.6.0 
    @fullcalendar/timegrid: 5.6.0 => 5.6.0 
    @graphql-codegen/cli: 2.16.4 => 2.16.4 
    @graphql-codegen/fragment-matcher: 3.3.3 => 3.3.3 
    @graphql-codegen/near-operation-file-preset: 2.5.0 => 2.5.0 
    @graphql-codegen/typescript: 2.8.7 => 2.8.7 (2.8.8)
    @graphql-codegen/typescript-operations: 2.5.12 => 2.5.12 
    @graphql-codegen/typescript-react-query: 4.1.0 => 4.1.0 
    @mui/icons-material: 5.11.9 => 5.11.9 
    @mui/lab: 5.0.0-alpha.80 => 5.0.0-alpha.80 
    @mui/material: 5.14.2 => 5.14.2 
    @mui/styles: 5.14.1 => 5.14.1 
    @mui/system: 5.14.1 => 5.14.1 (5.14.4)
    @nrwl/cli: 15.4.8 => 15.4.8 
    @nx/cypress: 16.6.0 => 16.6.0 
    @nx/detox: 16.6.0 => 16.6.0 
    @nx/jest: 16.6.0 => 16.6.0 
    @nx/js: 16.6.0 => 16.6.0 
    @nx/linter: 16.6.0 => 16.6.0 
    @nx/react: 16.6.0 => 16.6.0 
    @nx/react-native: 16.6.0 => 16.6.0 
    @nx/vite: 16.6.0 => 16.6.0 
    @nx/web: 16.6.0 => 16.6.0 
    @nx/workspace: 16.6.0 => 16.6.0 
    @pmmmwh/react-refresh-webpack-plugin: 0.5.7 => 0.5.7 
    @react-native-async-storage/async-storage: 1.17.10 => 1.17.10 
    @react-native-camera-roll/camera-roll: 5.2.0 => 5.2.0 
    @react-native-clipboard/clipboard: 1.11.1 => 1.11.1 
    @react-native-community/cli: 11.3.5 => 11.3.5 
    @react-native-community/cli-platform-android: 11.3.5 => 11.3.5 
    @react-native-community/cli-platform-ios: 11.3.5 => 11.3.5 
    @react-native-community/eslint-config: 2.0.0 => 2.0.0 
    @react-native-community/netinfo: 8.3.0 => 8.3.0 
    @react-native-community/progress-bar-android: 1.0.4 => 1.0.4 
    @react-native-community/progress-view: 1.3.1 => 1.3.1 
    @react-native-community/push-notification-ios: 1.10.1 => 1.10.1 
    @react-native-community/slider: 4.1.12 => 4.1.12 
    @react-native-firebase/app: 12.1.0 => 12.1.0 
    @react-native-firebase/dynamic-links: 12.1.0 => 12.1.0 
    @react-native-firebase/messaging: 12.1.0 => 12.1.0 
    @react-native-masked-view/masked-view: 0.2.6 => 0.2.6 
    @react-native/metro-config: 0.72.9 => 0.72.9 
    @react-navigation/material-top-tabs: 5.3.19 => 5.3.19 
    @react-navigation/native: 5.9.8 => 5.9.8 
    @react-navigation/stack: 5.14.9 => 5.14.9 
    @rnx-kit/metro-config: 1.3.5 => 1.3.5 
    @rnx-kit/metro-plugin-typescript: 0.3.3 => 0.3.3 
    @sendbird/chat: 4.9.3 => 4.9.3 (4.9.8)
    @sendbird/uikit-react: 3.6.4 => 3.6.4 
    @sendbird/uikit-react-native: 2.1.0 => 2.1.0 
    @sentry/cli: 2.3.1 => 2.3.1 (1.74.4, 1.75.2)
    @sentry/react: 7.5.0 => 7.5.0 (7.32.1)
    @sentry/react-native: 4.14.0 => 4.14.0 
    @sentry/tracing: 7.5.0 => 7.5.0 (7.32.1)
    @splitsoftware/splitio: 10.21.1 => 10.21.1 
    @splitsoftware/splitio-react: 1.3.0 => 1.3.0 
    @splitsoftware/splitio-react-native: 0.0.1 => 0.0.1 
    @svgr/webpack: 6.1.2 => 6.1.2 (8.0.1)
    @swc/plugin-emotion: 2.5.49 => 2.5.49 
    @tanstack/react-query: 4.0.10 => 4.0.10 
    @tanstack/react-query-devtools: 4.0.10 => 4.0.10 
    @testing-library/jest-dom: 5.16.5 => 5.16.5 
    @testing-library/jest-native: 5.4.2 => 5.4.2 
    @testing-library/react: 13.4.0 => 13.4.0 
    @testing-library/react-hooks: 8.0.1 => 8.0.1 
    @testing-library/react-native: 12.1.2 => 12.1.2 
    @testing-library/user-event: 14.1.1 => 14.1.1 
    @tinymce/tinymce-react: 4.3.0 => 4.3.0 
    @types/date-fns: 2.6.0 => 2.6.0 
    @types/dom-mediacapture-record: 1.0.11 => 1.0.11 
    @types/highlight-words-core: 1.2.1 => 1.2.1 
    @types/jest: 29.4.0 => 29.4.0 (29.5.3)
    @types/lodash: 4.14.178 => 4.14.178 
    @types/mixpanel-browser: 2.36.0 => 2.36.0 
    @types/node: 18.14.4 => 18.14.4 (20.5.0, 14.18.54)
    @types/peerjs: 1.1.0 => 1.1.0 
    @types/react: 18.0.28 => 18.0.28 (18.0.25)
    @types/react-csv: 1.1.3 => 1.1.3 
    @types/react-custom-scrollbars: 4.0.10 => 4.0.10 
    @types/react-dom: 18.0.9 => 18.0.9 
    @types/react-highlight-words: 0.16.4 => 0.16.4 
    @types/react-native: 0.72.2 => 0.72.2 
    @types/react-native-background-timer: 2.0.0 => 2.0.0 
    @types/react-native-incall-manager: 3.2.1 => 3.2.1 
    @types/react-native-push-notification: 7.3.3 => 7.3.3 
    @types/react-native-video: 5.0.9 => 5.0.9 
    @types/react-native-webrtc: 1.75.4 => 1.75.4 
    @types/react-table: 7.7.14 => 7.7.14 
    @types/react-test-renderer: 16.9.5 => 16.9.5 
    @types/react-virtualized-auto-sizer: 1.0.1 => 1.0.1 
    @types/react-window: 1.8.5 => 1.8.5 
    @types/react-window-infinite-loader: 1.0.6 => 1.0.6 
    @types/showdown: 2.0.1 => 2.0.1 
    @types/uuid: 8.3.3 => 8.3.3 
    @types/voximplant-websdk: 3.0.34 => 3.0.34 
    @typescript-eslint/eslint-plugin: 5.44.0 => 5.44.0 (3.10.1, 5.62.0)
    @typescript-eslint/parser: 5.44.0 => 5.44.0 (3.10.1, 5.62.0)
    @vitejs/plugin-react: 3.0.0 => 3.0.0 
    @vitejs/plugin-react-swc: 3.2.0 => 3.2.0 
    @vitest/coverage-c8: ~0.25.8 => 0.25.8 
    @vitest/ui: 0.25.8 => 0.25.8 
    ContextAPIMixpanel:  0.0.1 
    HelloWorld:  0.0.1 
    MixpanelDemo:  0.0.1 
    RNCalendarEventsExample:  0.0.1 
    ReactNativeBlobUtilWin:  0.0.1 
    SimpleMixpanel:  0.0.1 
    amazon-cognito-identity-js: 5.1.0 => 5.1.0 (6.3.3)
    amazon-cognito-identity-js/internals:  undefined ()
    appcenter: 4.4.3 => 4.4.3 
    appcenter-cli: 2.12.0 => 2.12.0 
    aws-amplify: ^5.3.8 => 5.3.8 
    aws-sdk: 2.1074.0 => 2.1074.0 
    babel-jest: 29.4.1 => 29.4.1 (29.6.2)
    babel-plugin-import: 1.13.5 => 1.13.5 
    babel-plugin-lodash: 3.3.4 => 3.3.4 
    babel-plugin-module-resolver: 4.1.0 => 4.1.0 
    chart.js: 3.7.0 => 3.7.0 
    chart.js-auto:  undefined ()
    chart.js-helpers:  undefined ()
    chartjs-plugin-datalabels: 2.2.0 => 2.2.0 
    chartjs-plugin-zoom: 1.2.1 => 1.2.1 
    check-password-strength: 2.0.5 => 2.0.5 
    classcat: 5.0.3 => 5.0.3 
    clipboard: 2.0.6 => 2.0.6 
    core-js: 3.6.5 => 3.6.5 (2.6.12, 3.32.0, 1.2.7)
    cron-parser: 4.2.1 => 4.2.1 
    cronstrue: 1.122.0 => 1.122.0 
    css-loader: 6.4.0 => 6.4.0 
    cypress: 12.7.0 => 12.7.0 
    date-fns: 2.23.0 => 2.23.0 (2.30.0, 2.29.3)
    dotenv: 16.0.0 => 16.0.0 (16.3.1, 10.0.0, 8.6.0)
    entities: 4.5.0 => 4.5.0 (2.2.0, 3.0.1, 2.0.3)
    eslint: 8.15.0 => 8.15.0 
    eslint-config-prettier: 8.1.0 => 8.1.0 (6.15.0)
    eslint-config-react: 1.1.7 => 1.1.7 
    eslint-config-react-app: 7.0.0 => 7.0.0 
    eslint-plugin-cypress: 2.10.3 => 2.10.3 
    eslint-plugin-import: 2.27.5 => 2.27.5 (2.28.0)
    eslint-plugin-jsx-a11y: 6.7.1 => 6.7.1 
    eslint-plugin-lodash: 7.4.0 => 7.4.0 
    eslint-plugin-prettier: 4.0.0 => 4.0.0 (3.1.2)
    eslint-plugin-react: 7.32.2 => 7.32.2 (7.33.1)
    eslint-plugin-react-hooks: 4.6.0 => 4.6.0 
    eslint-plugin-testing-library: 5.11.0 => 5.11.0 (5.11.1)
    example:  0.0.1 
    fake-indexeddb: 3.1.7 => 3.1.7 
    graphql: 16.6.0 => 16.6.0 (15.8.0)
    highlight-words-core: 1.2.2 => 1.2.2 
    history: 5.3.0 => 5.3.0 
    html-webpack-plugin: 5.5.0 => 5.5.0 
    humanize-duration: 3.25.1 => 3.25.1 
    i18next: 20.6.1 => 20.6.1 
    idb: 7.0.0 => 7.0.0 (5.0.6)
    identity-obj-proxy: 3.0.0 => 3.0.0 
    ifdef-loader: 2.3.2 => 2.3.2 
    imask: 6.0.7 => 6.0.7 
    ionicons: 5.0.0 => 5.0.0 
    ionicons-loader:  undefined ()
    ionicons/icons:  5.0.0 
    jest: 29.4.1 => 29.4.1 
    jest-circus: 29.4.1 => 29.4.1 (29.6.2)
    jest-coverage-badges: 1.1.2 => 1.1.2 
    jest-environment-jsdom: 29.4.1 => 29.4.1 
    jest-fetch-mock: 3.0.3 => 3.0.3 
    jest-localstorage-mock: 2.4.21 => 2.4.21 
    jest-react-native: 18.0.0 => 18.0.0 
    jest-resolve: 27.4.5 => 27.4.5 (29.6.2)
    jest-watch-typeahead: 1.0.0 => 1.0.0 
    jsdom: ~20.0.3 => 20.0.3 
    jsonwebtoken: 9.0.0 => 9.0.0 
    libphonenumber-js: 1.9.49 => 1.9.49 
    libphonenumber-js-core:  1.0.0 
    libphonenumber-js-max:  1.0.0 
    libphonenumber-js-min:  1.0.0 
    libphonenumber-js-mobile:  1.0.0 
    lodash: 4.17.21 => 4.17.21 
    logrocket: 1.0.14 => 1.0.14 
    lottie-react-native: 5.1.4 => 5.1.4 
    metro: 0.76.7 => 0.76.7 
    metro-babel-register: 0.76.7 => 0.76.7 
    metro-react-native-babel-preset: 0.76.7 => 0.76.7 
    metro-react-native-babel-transformer: 0.76.7 => 0.76.7 
    metro-resolver: 0.76.7 => 0.76.7 
    mime: 3.0.0 => 3.0.0 (2.6.0, 1.6.0)
    mixpanel-browser: 2.42.1 => 2.42.1 
    mixpanel-react-native: 1.3.7 => 1.3.7 
    mobx: 6.3.3 => 6.3.3 
    mobx-persist-store: 1.0.3 => 1.0.3 
    mobx-react-lite: 3.2.1 => 3.2.1 
    notistack: 2.0.3 => 2.0.3 
    nx: 16.6.0 => 16.6.0 (15.4.8)
    patch-package: 6.4.7 => 6.4.7 
    peerjs: 1.4.7 => 1.4.7 
    postinstall-postinstall: 2.1.0 => 2.1.0 
    prettier: 2.8.0 => 2.8.0 (2.8.8)
    pusher-js: 7.4.0 => 7.4.0 
    react: 18.2.0 => 18.2.0 
    react-app-polyfill: 3.0.0 => 3.0.0 
    react-chartjs-2: 3.2.0 => 3.2.0 
    react-csv: 2.2.2 => 2.2.2 
    react-custom-scrollbars: 4.2.1 => 4.2.1 
    react-dom: 18.2.0 => 18.2.0 
    react-highlight-words: 0.18.0 => 0.18.0 
    react-hook-form: 7.22.5 => 7.22.5 
    react-i18next: 12.0.0 => 12.0.0 
    react-idle-timer: 5.4.1 => 5.4.1 
    react-lottie: 1.2.3 => 1.2.3 
    react-native: 0.72.3 => 0.72.3 
    react-native-audio-recorder-player: 3.5.3 => 3.5.3 
    react-native-background-timer: 2.4.1 => 2.4.1 
    react-native-blob-util: 0.16.4 => 0.16.4 
    react-native-bootsplash: ^4.7.5 => 4.7.5 
    react-native-bouncy-checkbox: 3.0.4 => 3.0.4 (3.0.2)
    react-native-calendar-events: https://github.com/wmcmahan/react-native-calendar-events => 2.2.0 
    react-native-calendars: 1.1293.0 => 1.1293.0 
    react-native-chart-kit: 6.11.0 => 6.11.0 
    react-native-cli: 2.0.1 => 2.0.1 
    react-native-code-push: 7.1.0 => 7.1.0 
    react-native-config: 1.4.6 => 1.4.6 
    react-native-config-node: 0.0.3 => 0.0.3 
    react-native-confirmation-code-field: 7.1.0 => 7.1.0 
    react-native-date-picker: 4.2.6 => 4.2.6 
    react-native-device-info: 8.3.1 => 8.3.1 
    react-native-dialog: 8.2.0 => 8.2.0 
    react-native-document-picker: 8.1.1 => 8.1.1 
    react-native-document-scanner-plugin: 0.6.0 => 0.6.0 
    react-native-draggable: 3.3.0 => 3.3.0 
    react-native-error-boundary: 1.1.14 => 1.1.14 
    react-native-fast-image: 8.6.3 => 8.6.3 
    react-native-file-access: 2.5.2 => 2.5.2 
    react-native-gesture-handler: 1.10.3 => 1.10.3 
    react-native-image-picker: 4.6.0 => 4.6.0 
    react-native-image-resizer: 1.4.5 => 1.4.5 
    react-native-image-to-pdf: 1.2.0 => 1.2.0 
    react-native-image-viewing: 0.2.2 => 0.2.2 
    react-native-incall-manager: 3.3.0 => 3.3.0 
    react-native-keychain: 8.0.0 => 8.0.0 
    react-native-linear-gradient: 2.5.6 => 2.5.6 
    react-native-localize: 2.2.4 => 2.2.4 
    react-native-markdown-display: 7.0.0-alpha.2 => 7.0.0-alpha.2 
    react-native-modal: 13.0.0 => 13.0.0 
    react-native-navigation-bar-color: 2.0.1 => 2.0.1 
    react-native-onesignal: 4.4.0 => 4.4.0 
    react-native-orientation-locker: 1.3.1 => 1.3.1 
    react-native-otp-verify: 1.0.4 => 1.0.4 
    react-native-pdf: 6.6.2 => 6.6.2 
    react-native-peerjs: 1.0.4 => 1.0.4 
    react-native-permissions: 3.6.1 => 3.6.1 
    react-native-push-notification: 8.1.1 => 8.1.1 
    react-native-reanimated: ^3.4.2 => 3.4.2 
    react-native-render-html: 6.3.4 => 6.3.4 
    react-native-safe-area-context: 3.3.2 => 3.3.2 
    react-native-screens: 3.18.2 => 3.18.2 
    react-native-share: 7.2.0 => 7.2.0 
    react-native-signature-canvas: 4.5.0 => 4.5.0 
    react-native-skeleton-placeholder: 5.0.0 => 5.0.0 
    react-native-sound: 0.11.1 => 0.11.1 
    react-native-svg: 13.11.0 => 13.11.0 
    react-native-svg-transformer: 1.0.0 => 1.0.0 
    react-native-swiper: 1.6.0 => 1.6.0 
    react-native-tab-view: 2.16.0 => 2.16.0 
    react-native-toast-message: 2.1.0 => 2.1.0 
    react-native-url-polyfill: 1.3.0 => 1.3.0 
    react-native-uuid: 2.0.1 => 2.0.1 
    react-native-video: 6.0.0-alpha.3 => 6.0.0-alpha.3 
    react-native-voip-call: 1.1.1 => 1.1.1 
    react-native-webrtc: 1.106.1 => 1.106.1 
    react-native-webview: 11.22.7 => 11.22.7 
    react-refresh: 0.10.0 => 0.10.0 (0.14.0, 0.4.3)
    react-router-dom: 6.4.3 => 6.4.3 
    react-table: 7.8.0 => 7.8.0 
    react-table-sticky: 1.1.3 => 1.1.3 
    react-test-renderer: 18.2.0 => 18.2.0 
    react-virtualized-auto-sizer: 1.0.6 => 1.0.6 
    react-window: 1.8.8 => 1.8.8 
    react-window-infinite-loader: 1.0.8 => 1.0.8 
    react-zendesk: 0.1.13 => 0.1.13 
    regenerator-runtime: 0.13.7 => 0.13.7 (0.14.0, 0.11.1, 0.13.11)
    sendbird-calls: 1.9.0 => 1.9.0 
    sendbird-uikit: 2.7.1 => 2.7.1 
    showdown: 2.1.0 => 2.1.0 
    style-loader: 3.3.0 => 3.3.0 
    stylus: 0.55.0 => 0.55.0 
    stylus-loader: 7.1.0 => 7.1.0 
    toggle-switch-react-native: 3.3.0 => 3.3.0 
    ts-jest: 29.1.0 => 29.1.0 
    ts-node: 10.9.1 => 10.9.1 
    ts-pnp: 1.1.6 => 1.1.6 
    tslib: 2.3.0 => 2.3.0 (1.14.1, 2.6.1, 2.4.1)
    tslint: ~6.1.0 => 6.1.3 
    typescript: 4.8.4 => 4.8.4 
    url-loader: 4.1.1 => 4.1.1 
    uuid: 8.3.2 => 8.3.2 (3.4.0, 7.0.3, 3.3.2)
    vite: 4.0.1 => 4.0.1 (4.4.9)
    vite-plugin-checker: 0.6.0 => 0.6.0 
    vite-plugin-conditional-compiler: 0.1.1 => 0.1.1 
    vite-plugin-dts: ~1.7.1 => 1.7.3 
    vite-plugin-eslint: 1.8.1 => 1.8.1 
    vite-plugin-require-transform: 1.0.12 => 1.0.12 
    vite-plugin-rewrite-all: 1.0.1 => 1.0.1 
    vite-tsconfig-paths: 4.0.2 => 4.0.2 
    vitest: 0.25.8 => 0.25.8 
    voximplant-websdk: 4.6.1-2394 => 4.6.1-2394 
    webpack: 5.75.0 => 5.75.0 
    webpack-bundle-analyzer: 4.5.0 => 4.5.0 
    webpack-merge: 5.8.0 => 5.8.0 (5.9.0)
  npmGlobalPackages:
    corepack: 0.14.2
    npm: 8.19.2
    serve: 14.2.0
    yarn: 1.22.19

Describe the bug

After upgrading our NX project to NX 16 & React Native 0.72.3, I’m getting an error when importing Auth from amplify-aws

ERROR  TypeError: Cannot read property '__extends' of undefined, js engine: hermes
WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'Auth' of undefined

this is my import

import { Amplify, Auth, Storage } from 'aws-amplify';

At first, I couldn’t import amplify as well (when we were on version aws-amplify - 4.2.9), After upgrading to the latest aws-amplify-5.3.8, I’m able to import Storage & Amplify, but not Auth. After investigating, I found the issue is with __extends(AuthClass, _super); line 10 on node_modules/@aws-amplify/auth/lib-esm/Auth.js. If I’m comparing it to Storage.js which works, I can see their extends are implemented differently.

Expected behavior

Being able to import both Storage, Amplify and Auth.

Reproduction steps

  1. Run a RN 0.72.3 app on NX 16 project.
  2. Run console.log({Auth})

Code Snippet

// Put your code below this line.

Log output

 ERROR  TypeError: Cannot read property '__extends' of undefined, js engine: hermes
 WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'Auth' of undefined
TypeError: Cannot read property 'Auth' of undefined
    at get (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:217253:65)
    at initAWS (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:217080:55)
    at ?anon_0_ (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:172657:68)
    at next (native)
    at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:172684:26)
    at _next (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:172703:29)
    at tryCallOne (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:34512:26)
    at _callTimer (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:34391:17)
    at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:34436:17)
    at callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:34642:44)
    at __callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:3289:46)
    at anonymous (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:3063:45)
    at __guard (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:3262:15)
    at flushedQueue (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:3062:21)
    at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.lagunahealth.app:3056:33)

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 3
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Update: It appears that theses errors are related to option unstable_enablePackageExports in the metro config, which was introduced along with the nx/react-native preset lately.

According to the docs this option will cause Metro to read the exports from package.json, while providing a fallback when this is not possible.

I’m not sure whether this is the cause or just a workaround, but setting option unstable_enablePackageExports to false in metro.config.js seems to resolve the errors in my case:

  resolver: {
    assetExts: assetExts.filter((ext) => ext !== 'svg'),
    sourceExts: [...sourceExts, 'svg'],
    blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
    unstable_enableSymlinks: true,
    unstable_enablePackageExports: false,
  },

@gillicarmon or @david-gettins, can you maybe confirm this?

Update: It appears that theses errors are related to option unstable_enablePackageExports in the metro config, which was introduced along with the nx/react-native preset lately.

According to the docs this option will cause Metro to read the exports from package.json, while providing a fallback when this is not possible.

I’m not sure whether this is the cause or just a workaround, but setting option unstable_enablePackageExports to false in metro.config.js seems to resolve the errors in my case:

  resolver: {
    assetExts: assetExts.filter((ext) => ext !== 'svg'),
    sourceExts: [...sourceExts, 'svg'],
    blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
    unstable_enableSymlinks: true,
    unstable_enablePackageExports: false,
  },

@gillicarmon or @david-gettins, can you maybe confirm this?

I can confirm that this worked for me.

@rudgal I’ll give it a try and get back to you

@gillicarmon, thank you for the additional information and rolling back to verify!

@david-gettins, this is also very helpful to know it’s happening when using the amazon-cognito-identity-js by itself and not even importing Auth.

Would both of you mind trying an upgrade to v5.3.10 of Amplify (latest version)? We’ve implemented quite a few changes in the last few versions since v5.3.6. If this does not resolve the issues, then I’ll have some further follow up questions on the Nx and React Native side… but trying to see if we can isolate these issues on the Amplify side first.

I have a similar issue after upgrading to React Native 0.72.3. I am using amazon-cognito-identity-js directly not via aws-amplify. I am also using NX 16. Upon calling authenticateUser I get the error:

TypeError: Cannot read property '__extends' of undefined, js engine: hermes

It is thrown when attempting to call:

const awsCryptoHash = new Sha256();

That is called from the hash function in AuthenticationHelper.js.

Hello, @gillicarmon and thanks for creating this issue. If you recently made the update from v4.2.9 of Amplify to the most recent v5.3.8, can you see if taking the following steps resolves the issue:

  1. Delete your node_modules folder.
  2. Delete your package-lock.json file (if you have one).
  3. Run npm install to reinstall all dependencies.
  4. If the issue isn’t resolved after that, can you try rolling back to Amplify v5.3.6 to see if the error persists?

Thank you for the quick response. After the first 3 steps, the error remained. After changing version to v5.3.6 I was able to import Auth, but now I’m getting the same error after calling Auth.currentSession(); After quick debugging, seems like the issue is in file node_modules/@aws-amplify/auth/lib-esm/Auth.js, line 1430 (inside currentUserPoolUser , .then(function () { return __awaiter(_this, void 0, void 0, function () {

The error:

TypeError: Cannot read property '__extends' of undefined, js engine: hermes
TypeError: Cannot read property '__awaiter' of undefined

Update: It appears that theses errors are related to option unstable_enablePackageExports in the metro config, which was introduced along with the nx/react-native preset lately.

According to the docs this option will cause Metro to read the exports from package.json, while providing a fallback when this is not possible.

I’m not sure whether this is the cause or just a workaround, but setting option unstable_enablePackageExports to false in metro.config.js seems to resolve the errors in my case:

  resolver: {
    assetExts: assetExts.filter((ext) => ext !== 'svg'),
    sourceExts: [...sourceExts, 'svg'],
    blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
    unstable_enableSymlinks: true,
    unstable_enablePackageExports: false,
  },

@gillicarmon or @david-gettins, can you maybe confirm this?

Worked, thanks!

same error here after nx/react-native upgrade:

    "amazon-cognito-identity-js": "^5.2.14",
    "aws-amplify": "^5.0.14",
    "aws-amplify-react-native": "^7.0.2",
    "nx": "16.7.4",
    "react-native": "0.72.3",

also upgrading to recommended versions as described above did not resolve the issue for me:

    "amazon-cognito-identity-js": "^6.3.5",
    "aws-amplify": "^5.3.10",
    "aws-amplify-react-native": "^7.0.6",
    "nx": "16.7.4",
    "react-native": "0.72.3",

@gillicarmon, thank you for the additional information and rolling back to verify!

@david-gettins, this is also very helpful to know it’s happening when using the amazon-cognito-identity-js by itself and not even importing Auth.

Would both of you mind trying an upgrade to v5.3.10 of Amplify (latest version)? We’ve implemented quite a few changes in the last few versions since v5.3.6. If this does not resolve the issues, then I’ll have some further follow up questions on the Nx and React Native side… but trying to see if we can isolate these issues on the Amplify side first.

I have updated to the latest amazon-cognito-identity-js@6.3.5 but still face the same issue.

Having this exact same issue with importing Amplify.

"aws-amplify": "5.3.10",
"react-native": "0.72.4",
"nx": "16.5.2",

Wasn’t an upgrade in my case but a fresh expo app with nx, to which I added aws-amplify@latest.