amplify-js: AuthError - Error: Amplify has not been configured correctly. (aws-amplify 3.4.0, auth 3.4.31, ui-react 1.1.0)

Before opening, please confirm:

App Id

dj8d92h79lafk

Region

us-west-2

Amplify Console feature

Not applicable

Describe the bug

I’m seeing this AuthError error which has been reported several times before but none of the recommended solutions in those tickets have worked for me yet. I’m under the impression that some of the dependencies specified in my package.json file are incompatible with each other but I haven’t been able to get it sorted.

Here’s the console 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 scenarios:

            1. Did you run `amplify push` after adding auth via `amplify add auth`?
                See https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup for more information

            2. This could also be caused by multiple conflicting versions of amplify packages, see (https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js) for help upgrading Amplify packages.

Here’s my package.json file:

{
  "name": "dummyappname",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@aws-amplify/auth": "^3.4.31",
    "@aws-amplify/ui-react": "^1.1.0",
    "@testing-library/jest-dom": "^5.12.0",
    "@testing-library/react": "^11.2.6",
    "@testing-library/user-event": "^12.8.3",
    "aws-amplify": "^3.4.0",
    "aws-sdk": "^2.903.0",
    "bootstrap": "^3.4.1",
    "node-sass": "^5.0.0",
    "react": "^17.0.2",
    "react-bootstrap": "^1.5.2",
    "react-bootstrap-validation": "^0.1.11",
    "react-dom": "^17.0.2",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "react-vis": "^1.11.7",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

And here’s the app entry point code:

import Amplify, { Auth } from 'aws-amplify';
import awsmobile from './aws-exports';
import './App.css';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
import React from "react";
import { withAuthenticator } from '@aws-amplify/ui-react';

function App() {

    Amplify.configure(awsmobile);
    Auth.configure(awsmobile);

    return (
        <Router>
            <Switch>
                <div className="app">

                    <Route exact path={["/", "/home"]}>
                        <div>Hello, World</div>
                    </Route>

                </div>
            </Switch>
        </Router>
    )
}

export default withAuthenticator(App);

Expected behavior

The basic authentication functionality as described in this tutorial: https://docs.amplify.aws/lib/auth/getting-started/q/platform/js#enable-sign-up-sign-in-and-sign-out

Reproduction steps

  1. Use the package.json
  2. Run the app entry code

Build Settings

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 27 (9 by maintainers)

Most upvoted comments

Should I roll back to a previous version?

Yes see if you get error with older version. If not then its issue with new update.

Thanks mate, I have rolled back to 3.3.27 and my problem is resolved. This version also seems to have all the core packages as expected, in the latest version 4.0.0 I was missing Auth, Cache and one or two others.

Going to close this for now as we have not heard back from the original poster in nearly two weeks and some folks have been able to fix it/find a workaround. If you’re still experiencing this issue or something similar, please open a separate issue and provide us the details of your environment so we can better identify the cause and find a solution for you.

After all this chatter I tried it and now it seems to be resolved. Also this new update v4 has increased at least 100Kb of extra javascript than v3 version. Here are my dependancies.

{
  "dependencies": {
    "@aws-amplify/api": "^4.0.0",
    "@aws-amplify/auth": "^4.0.0",
    "@aws-amplify/core": "^4.0.2",
}

My mistake was I only had core on v4 and others were on v3 so it was not working. Now I got all of them to v4 and now they are working.