amazon-cognito-auth-js icon indicating copy to clipboard operation
amazon-cognito-auth-js copied to clipboard

[ts] Cannot find module 'amazon-cognito-auth-js'.

Open chanduchama opened this issue 8 years ago • 12 comments

Hi Team,

I am trying to use "amazon-cognito-auth-js" inside my angular2 web application. Executed the following steps to add the dependencies.

  1. npm install --save amazon-cognito-auth-js
  2. import {CognitoAuth} from 'amazon-cognito-auth-js';

I see that the dependencies are updated in package.json. This is how it look inside my package.json file.

"amazon-cognito-auth-js": "^1.0.0", "amazon-cognito-identity-js": "^1.19.0", "aws-sdk": "^2.6.0",

Web app is generated using angualr cli. But while building the application i am receiving the following error. "[ts] Cannot find module 'amazon-cognito-auth-js'."

Can someone help me to resolve this?

Regards, Sarath

chanduchama avatar Oct 12 '17 12:10 chanduchama

+1

pabloow avatar Oct 15 '17 05:10 pabloow

It seems to be a typescript issue. This package does not have typescript support.

itrestian avatar Oct 19 '17 18:10 itrestian

+1

joeswiggin avatar Oct 29 '17 16:10 joeswiggin

+1

luomavaltteri avatar Nov 02 '17 10:11 luomavaltteri

I seem to also be getting this issue without ts, using just the vanilla create react app.

stvnksslr avatar Nov 02 '17 18:11 stvnksslr

In package.json: "main": "lib/index.js", "module": "es/index.js", Are nowhere to be found in amazon-cognito-auth, so I used:

import { CognitoAuth } from 'amazon-cognito-auth-js/dist/amazon-cognito-auth';

To work around the incorrect values in package.json for now

deeperid avatar Nov 03 '17 02:11 deeperid

+1111

bhao-speedline avatar Dec 01 '17 23:12 bhao-speedline

Inspired by the solution given by @deeperid, I do const amazonCognitoAuth: any = require("amazon-cognito-auth-js/dist/amazon-cognito-auth");

bhao-speedline avatar Dec 05 '17 18:12 bhao-speedline

If the project has React structure, then this will work: import { CognitoAuth } from 'amazon-cognito-auth-js/dist/amazon-cognito-auth';

yuntuowang avatar Dec 07 '17 00:12 yuntuowang

Is the plan to fix this? It's not intuitive to have to use that workaround.

dpwrussell avatar Dec 24 '17 18:12 dpwrussell

@dpwrussell yes we are on track of fixing this! Thanks.

Currently, this workaround works because the bundled auth SDK file is under /dist directory.

yuntuowang avatar Dec 25 '17 00:12 yuntuowang

@yuntuowang I have tried that. It does not work in Ionic+angular+typescript Mobile Project.

Any suggestions?

engharb avatar Dec 18 '18 15:12 engharb