aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

AmazonLocationServicesProvider - ensure credentials error No Auth module registered in Amplify #8687

Closed IsaacTrevino closed 3 years ago

IsaacTrevino commented 3 years ago

Amplify Geo and MapLibre issues

Environment information

``` # Put output below this line System: OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (32) x64 AMD Ryzen 9 3950X 16-Core Processor Memory: 43.10 GB / 50.15 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node Yarn: 1.22.4 - /mnt/c/Users/isaac/AppData/Roaming/npm/yarn npm: 7.20.3 - ~/.nvm/versions/node/v14.16.0/bin/npm npmPackages: @apollo/client: ^3.3.21 => 3.4.1 @apollo/client/cache: undefined () @apollo/client/core: undefined () @apollo/client/errors: undefined () @apollo/client/link/batch: undefined () @apollo/client/link/batch-http: undefined () @apollo/client/link/context: undefined () @apollo/client/link/core: undefined () @apollo/client/link/error: undefined () @apollo/client/link/http: undefined () @apollo/client/link/persisted-queries: undefined () @apollo/client/link/retry: undefined () @apollo/client/link/schema: undefined () @apollo/client/link/utils: undefined () @apollo/client/link/ws: undefined () @apollo/client/react: undefined () @apollo/client/react/components: undefined () @apollo/client/react/context: undefined () @apollo/client/react/data: undefined () @apollo/client/react/hoc: undefined () @apollo/client/react/hooks: undefined () @apollo/client/react/parser: undefined () @apollo/client/react/ssr: undefined () @apollo/client/testing: undefined () @apollo/client/utilities: undefined () @aws-amplify/api: ^4.0.8 => 4.0.8 @aws-amplify/auth: ^4.2.0 => 4.2.0 @aws-amplify/core: ^4.2.2 => 4.2.2 (4.2.1-geo.12+7be4beb5f) @aws-amplify/geo: * => 0.0.2-geo.6646+7be4beb5f @aws-amplify/storage: ^4.3.3 => 4.3.3 @babel/cli: ^7.14.8 => 7.14.8 @babel/core: ^7.14.8 => 7.14.8 (7.12.3) @babel/preset-env: ^7.14.8 => 7.14.9 (7.12.1) @date-io/dayjs: ^1.3.13 => 1.3.13 @fortawesome/fontawesome-svg-core: ^1.2.35 => 1.2.35 @fortawesome/free-brands-svg-icons: ^5.15.3 => 5.15.3 @fortawesome/free-regular-svg-icons: ^5.15.3 => 5.15.3 @fortawesome/free-solid-svg-icons: ^5.15.3 => 5.15.3 @fortawesome/react-fontawesome: ^0.1.14 => 0.1.14 @fullcalendar/core: 4.4.2 => 4.4.2 @fullcalendar/daygrid: 4.4.2 => 4.4.2 @fullcalendar/interaction: 4.4.2 => 4.4.2 @fullcalendar/list: 4.4.2 => 4.4.2 @fullcalendar/react: 4.4.2 => 4.4.2 @fullcalendar/timegrid: 4.4.2 => 4.4.2 @fullcalendar/timeline: 4.4.2 => 4.4.2 @mapbox/mapbox-gl-style-spec: 13.21.0 @maplibre/maplibre-gl-geocoder: ^1.0.0 => 1.0.0 @maplibre/maplibre-gl-style-spec: 14.1.0-dev @material-ui/core: ^4.12.2 => 4.12.3 @material-ui/icons: ^4.11.2 => 4.11.2 @material-ui/lab: ^4.0.0-alpha.60 => 4.0.0-alpha.60 @material-ui/pickers: ^3.3.10 => 3.3.10 @material-ui/styles: ^4.11.4 => 4.11.4 @react-pdf/renderer: ^2.0.16 => 2.0.17 @stripe/react-stripe-js: ^1.4.1 => 1.4.1 @stripe/stripe-js: ^1.16.0 => 1.16.0 apexcharts: ^3.27.3 => 3.27.3 apollo-cache-persist: ^0.1.1 => 0.1.1 assert: 1.0.0 aws-amplify: ^4.2.1-geo.14 => 4.2.2 aws-appsync-auth-link: ^3.0.6 => 3.0.6 aws-appsync-subscription-link: ^3.0.8 => 3.0.8 axios: ^0.21.1 => 0.21.1 axios-mock-adapter: ^1.19.0 => 1.19.0 change-case: ^4.1.2 => 4.1.2 clsx: ^1.1.1 => 1.1.1 dayjs: ^1.10.6 => 1.10.6 expect.js: 0.3.1 formik: ^2.2.9 => 2.2.9 graphql: ^15.5.1 => 15.5.1 (14.0.0) js-cookie: ^3.0.0 => 3.0.0 (2.2.1) jss: ^10.7.1 => 10.7.1 localforage: ^1.9.0 => 1.9.0 lodash: ^4.17.21 => 4.17.21 mapbox-gl: ^2.3.1 => 2.4.0 maplibre-gl: ^1.15.2 => 1.15.2 maplibre-gl-js-amplify: ^1.0.2 => 1.0.2 notistack: ^1.0.10 => 1.0.10 nprogress: ^0.2.0 => 0.2.0 omit-deep-lodash: ^1.1.5 => 1.1.5 prop-types: ^15.7.2 => 15.7.2 react: ^17.0.2 => 17.0.2 react-apexcharts: ^1.3.9 => 1.3.9 react-color: ^2.19.3 => 2.19.3 react-dom: ^17.0.2 => 17.0.2 react-dropzone: ^11.3.4 => 11.3.4 react-feather: ^2.0.9 => 2.0.9 react-helmet: ^6.1.0 => 6.1.0 react-json-tree: ^0.15.0 => 0.15.0 react-lottie: ^1.2.3 => 1.2.3 react-map-gl: ^6.1.16 => 6.1.16 react-markdown: ^6.0.2 => 6.0.3 react-modal-image: ^2.5.0 => 2.5.0 react-number-format: ^4.6.4 => 4.6.4 react-perfect-scrollbar: ^1.5.8 => 1.5.8 react-quill: ^1.3.5 => 1.3.5 react-router-dom: ^5.2.0 => 5.2.0 react-scripts: ^4.0.3 => 4.0.3 react-text-mask: ^5.4.3 => 5.4.3 uuid: ^8.3.2 => 8.3.2 (3.4.0, 3.3.2) yup: ^0.32.9 => 0.32.9 npmGlobalPackages: @aws-amplify/cli: 5.2.2-geo.0 npm-check-updates: 11.8.3 npm: 7.20.3 tsc: 2.0.3 ```

Describe the bug

Receiving this error: Error: No credentials at AmazonLocationServicesProvider. (AmazonLocationServicesProvider.ts:138)

I'm using the modular approach @aws-amplify/geo as its required by

import { AmplifyMapLibreRequest } from "maplibre-gl-js-amplify";
Amplifiyer commented 3 years ago

@IsaacTrevino How are you configuring Amplify? Can you share your code snippet?

IsaacTrevino commented 3 years ago
import React from 'react';
import App from 'src/App';
import Amplify from 'aws-amplify';
import { Geo } from '@aws-amplify/geo';
import API from '@aws-amplify/api';
import Storage from '@aws-amplify/storage';
import Auth from '@aws-amplify/auth';
import awsconfig from './aws-exports';

Amplify.configure(awsconfig);

API.configure(awsconfig);
Auth.configure(awsconfig);
Storage.configure(awsconfig);
Geo.configure(awsconfig);

I tried without the import Amplify from 'aws-amplify' configuration as well but no luck.

Amplifiyer commented 3 years ago

Thanks @IsaacTrevino import Amplify from 'aws-amplify' should work fine and you don't even need individual category configure calls.

From your environment information's npm packages it seems not all aws-amplify packages are taken from geo tag. If you are installing aws-amplify you don't need to also install individual packages and can still use imports @aws-amplify/<category>. Can you reinstall aws-amplify package with geo tag and remove all other @aws-amplify/category packages that you may have in your package.json?

IsaacTrevino commented 3 years ago

I had no idea you could still use @aws-amplify/<category> without the need to install them individually. However, after deleting my package-lock.js and node-modules and then reinstalling, I get this error.

./node_modules/maplibre-gl-js-amplify/dist/AmplifyMapLibreRequest.js Module not found: Can't resolve '@aws-amplify/geo' in '/home/****/<project-name>/node_modules/maplibre-gl-js-amplify/dist'

Amplifiyer commented 3 years ago

hmm this is strange. Can you let us know the version of aws-amplify (from package.json) in your node_modules?

IsaacTrevino commented 3 years ago

Yes, the same one mentioned in Env Details above.

    "aws-amplify": "^4.2.1-geo.14"
    "maplibre-gl": "^1.15.2",
    "maplibre-gl-js-amplify": "^1.0.2",
    "@maplibre/maplibre-gl-geocoder": "^1.0.0",

I am using npm i --legacy-peer-dependencies for installing node-modules

Amplifiyer commented 3 years ago

I was able to reproduce it, it looks like semver issue where installing for ^4.2.1-geo.14 resolves in 4.2.2. Can you try updating the package.json with 4.2.1-geo.14 and installing it again?

IsaacTrevino commented 3 years ago

I still receive the same error regards to maplibre-gl-js-amplify needing @aws-amplify/geo.

It now seems if I install npm i aws-amplify@4.2.2, the Geo library is missing. image

Amplifiyer commented 3 years ago

Correct, aws-amplify@4.2.2 doesn't have the Geo library. Is it possible for you to host your sample app on github where I can reproduce? Using npm i --legacy-peer-dependencies with aws-amplify version 4.2.1-geo.14 in my package.json works fine.

IsaacTrevino commented 3 years ago

So I've tested the aws-amplify@geo aka aws-amplify@4.2.1-geo.14 or aws-amplify@4.2.1-geo.15 and it seems that maplibre-gl-js-amplify is breaking the aws-amplify library.

Somehow it's no longer reading the Auth library, showing an error: AuthError - Error: Amplify has not been configured correctly. The configuration object is missing required auth properties. This error is typically caused by one of the following

I will attempt to create a sample app and see if it works. Perhaps its another package that's also causing the issue.

Edit: I've tested without the maplibre-gl-js-amplify package and it seems Geo Class works. However I need to use maplibre-gl-js.

IsaacTrevino commented 3 years ago

Sample Amplify/Geo Project https://github.com/IsaacTrevino/AmplifyGeo

Having the same issue. How are you setting it up?

IsaacTrevino commented 3 years ago

https://github.com/IsaacTrevino/AmplifyGeo/pull/1 It seems that removing the carrat did the trick in package.json:

    "@aws-amplify/ui-react": "^1.2.8",
    "@maplibre/maplibre-gl-geocoder": "^1.0.0",
    "aws-amplify": "4.2.1-geo.15",
    "maplibre-gl": "^1.15.2",
    "maplibre-gl-js-amplify": "^1.0.2",

However this must be installed at the creation of the package-lock.json rather than installing individual packages afterwards.

Amplifiyer commented 3 years ago

@IsaacTrevino yes, If you use --save-exact while installing aws-amplify@geo the carat wouldn't be added automatically, or if you change the package.json to remove the carat, afterwards npm i would not cause any issues.

IsaacTrevino commented 3 years ago

Even though this is a fix, there seems to be DOM issues. Hopefully fixed on future updates.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.