Closed svzi closed 6 years ago
@svzi Can you check your node_modules/aws-amplify-angular directory to see if there is another aws-amplify installed in there, I saw that error before when there are multiple instance of aws-amplify installed on a project.
Hello @svzi - Your Ionic 3 app is typescript, yeah?
@elorzafe Thank you, I will check that tomorrow!
@haverchuck Yeah, it's typescript. Why do you ask?
@svzi Could it be having an issue with the aws-exports.js (i.e. the .js extension)?
@haverchuck How can I find out? Any idea?
I had the same issue - always seeing the message "No userPool"
My app is just the Tutorial https://aws-amplify.github.io/amplify-js/media/tutorials/building-ionic-4-apps/ but there is a piece of bad advice in there about renaming the file aws-exports.js
Since we are using TypeScript, change the name of the aws-exports file to aws-exports.ts.
If I don't rename the file then all works - if I rename the file, it does NOT work.
The problem is that the .ts
file isn't maintained by the aws cli and tools - only the .js
file is, so any configuration changes you made, like adding authentication isn't added to your .ts
file.
When you now run the app the typescript compiler/transpiler will overwrite the .js file (with correct configuration) with the configuration from the .ts
file...
Note that your IDE might hide the .js
file if you got a .ts
file with the same name.
Thanks @haverchuck for asking about the extension.
After playing around with all the suggestions, I found a silly mistake in my implementation. I did this:
import * as aws_exports from '../aws-exports';
Amplify.configure(aws_exports);
Instread of this:
import * as aws_exports from '../aws-exports';
Amplify.configure(aws_exports.default);
So to no ones surprise it didn't work. The comment from @haverchuck pointed me in the right direction. But I need to agree heavily to @developerjohan01. It's not a good idea to rename the .js to .ts, because of the reasons he described!
@developerjohan01 - Great catch on the CLI support issue for .ts extensions! I'll make sure the tutorial is updated.
The Amplify Angular guide recommends a script to change the exports file name upon build, to workaround this problem:
"start": "[ -f src/aws-exports.js ] && mv src/aws-exports.js src/aws-exports.ts || ng serve; ng serve",
"build": "[ -f src/aws-exports.js ] && mv src/aws-exports.js src/aws-exports.ts || ng build --prod; ng build --prod"
}```
I am still getting this issue with Angular AOT build
here is my config file aws-exports.ts
export default {
Auth: {
// // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
// // identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab',
// // REQUIRED - Amazon Cognito Region
region: 'xxxxx',
// // OPTIONAL - Amazon Cognito Federated Identity Pool Region
// // Required only if it's different from Amazon Cognito Region
// // identityPoolRegion: 'XX-XXXX-X',
// // OPTIONAL - Amazon Cognito User Pool ID
userPoolId: 'xxxxx',
// // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
userPoolWebClientId: 'dddd'
}
}
this is my code from app.module.ts
the below code will throw this error with development mode and AOT mode
import Amplify from '@aws-amplify/core';
import Auth from '@aws-amplify/auth';
import * as amplify from './aws-exports';
console.log('amplify config', amplify);
Amplify.configure(amplify);
this configuration works fine in development mode but not when building bundler files with AOT mode
import Amplify from '@aws-amplify/core';
import Auth from '@aws-amplify/auth';
import amplify from './aws-exports';
console.log('amplify config', amplify);
Amplify.configure(amplify);
why is this closed this is still an issue
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.
Hi there!
I'm currently trying to add authentication via aws-amplify (and aws-amplify-angular) to my Ionic 3 app.
When I run this piece of code:
I'm always getting this:
This is my aws-export.js file:
And I'm using this packages:
I've got one verified user in that user pool and I can access this pool via my serverless backend (AWS Lambda) with a different app client id (that I've created manually for the lambda access).
After searching in the issues I noticed that most "No userPool" error where reported in combination with Reat and an old version of aws-amplify. So I have no idea how I can solve my login issue.
Any help would be really much appreciated!