Reputation: 11
I'm getting the following error when running my angular applicationT:
Error: Amplify has not been configured correctly.
This error is typically caused by one of the following scenarios:
- Make sure you're passing the awsconfig object to Amplify.configure() in your app's entry point See https://aws-amplify.github.io/docs/js/authentication#configure-your-app for more information
- There might be multiple conflicting versions of aws-amplify or amplify packages in your node_modules. Try deleting your node_modules folder and reinstalling the dependencies with
yarn install
One strange thing is that this happens only with --prod
enabled.
It was fine until today, Sept 9th, but I don't know which package version is causing the issue. I already tried using the older ones from aws-amplify and aws-amplify-angular, but it seems to be other package. How could I know which one?
package.json
{
"name": "proyect",
"version": "0.5.2",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:prod": "ng build --buildOptimizer=true --optimization=true --prod=true",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.0",
"@angular/cdk": "~8.2.3",
"@angular/common": "~8.2.0",
"@angular/compiler": "~8.2.0",
"@angular/core": "~8.2.0",
"@angular/forms": "~8.2.0",
"@angular/material": "^8.2.3",
"@angular/platform-browser": "~8.2.0",
"@angular/platform-browser-dynamic": "~8.2.0",
"@angular/router": "~8.2.0",
"@ngrx/effects": "^8.6.0",
"@ngrx/store": "^8.6.0",
"@ngx-translate/core": "^12.1.2",
"@ngx-translate/http-loader": "^5.0.0",
"aws-amplify": "^3.0.7",
"aws-amplify-angular": "^5.0.7",
"bootstrap": "^4.5.0",
"chart.js": "^2.9.3",
"chartjs-plugin-datalabels": "^0.7.0",
"moment": "^2.26.0",
"ng2-charts": "^2.3.2",
"ngx-mask": "^8.2.0",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.25",
"@angular/cli": "~8.2.0",
"@angular/compiler-cli": "~8.2.0",
"@angular/language-service": "~8.2.0",
"@ngrx/store-devtools": "^9.1.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"json-server": "^0.16.1",
"karma": "^5.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"ng2-charts-schematics": "^0.1.7",
"protractor": "^7.0.0",
"ts-node": "8.5.0",
"tslint": "^5.20.1",
"typescript": "~3.5.3"
}
}
Upvotes: 1
Views: 6920
Reputation: 711
In my case, I found a solution that I never saw anywhere, more related to my code editor (Webstorm) I guess.
Context:
I renamed my aws-export.js to .ts, as recommanded in Amplify:
Depending on your TypeScript version you may need to rename aws-exports.js to aws-exports.ts prior to importing, or enable the allowJs compiler option in your tsconfig.
When I got the famous error, I noticed that my aws-export.ts didn't have any Auth property, and "contain" another file :
The .js version was well updated with everything, so I took its content to copy-past in my .ts version, and It's working.
Upvotes: 3
Reputation: 261
I have met the same situation. In my application I'm using only Auth component, so I have to add Auth.configure()
import { Amplify, Auth } from 'aws-amplify';
Amplify.configure(environment.amplify);
// The following code-line solved the issue
Auth.configure(environment.amplify);
Thanks to author of https://github.com/aws-amplify/amplify-js/issues/5429
Upvotes: 1
Reputation: 11
Seems like Auth.configure(params)
missing in your code.
pass the same params that you use for Amplify.configure(params)
Upvotes: 1