Reputation: 57
I am running an app with angular, amplify and cognito. when I do ng serve
to run the app I have this error.
I tried deleted all the nodes modules, package-lock.json but it does not change a thing
So I am wondering what should I change to make it works properly when doing ng serve.
ERROR in node_modules/amazon-cognito-identity-js/index.d.ts:1:1
- error TS6200: Definitions of the following identifiers conflict with
those in another file: NodeCallback, ClientMetadata, AuthenticationDetails,
CognitoUser, CognitoUserAttribute, CognitoUserPool, CognitoUserSession, CognitoAccessToken, CognitoIdToken, CognitoRefreshToken, CookieStorage
declare module 'amazon-cognito-identity-js' {
node_modules/aws-amplify/node_modules/amazon-cognito-identity-js/index.d.ts:1:1
1 declare module 'amazon-cognito-identity-js' {
Conflicts are in this file.
Upvotes: 2
Views: 2587
Reputation: 21
The amazon-cognito-identity-js
package is not needed and part of aws-amplify
.
My modules:
"@angular/animations": "~11.0.5",
"@angular/cdk": "^11.0.3",
"@angular/common": "~11.0.5",
"@angular/compiler": "~11.0.5",
"@angular/core": "~11.0.5",
"@angular/forms": "~11.0.5",
"@angular/material": "^11.0.3",
"@angular/platform-browser": "~11.0.5",
"@angular/platform-browser-dynamic": "~11.0.5",
"@angular/router": "~11.0.5",
"@aws-amplify/ui-angular": "^0.4.17-unstable.1",
"@types/graphql": "^14.5.0",
"angular-gridster2": "^10.1.7",
"aws-amplify": "^3.3.14-unstable.1",
"crypto-js": "^4.0.0",
"ini": "^2.0.0",
"linqts": "^1.14.3",
"ng-dynamic-component": "^8.0.0",
"node-fetch": "^2.6.1",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
write in polyfilss.ts:
(window as any).global = window;
directly into package.json:
"browser": {
"crypto": false
}
app-module aws-imports:
import Amplify from 'aws-amplify';
import {AmplifyUIAngularModule} from '@aws-amplify/ui-angular';
import awsmobile from '../aws-exports.js';
Amplify.configure(awsmobile);
in angular.json under .../build/options:
"allowedCommonJsDependencies": [
"crypto-js",
"@aws-sdk/eventstream-marshaller",
"buffer",
"js-cookie",
"@aws-crypto",
"zen-observable",
"@aws-sdk/util-utf8-node",
"@aws-crypto/sha256-js",
"@aws-crypto/crc32",
"@aws-sdk/util-buffer-from",
"@aws-sdk/smithy-client",
"@aws-sdk/middleware-serde",
"@aws-sdk/middleware-user-agent",
"@aws-sdk/middleware-retry",
"@aws-sdk/middleware-signing",
"@aws-sdk/middleware-content-length",
"@aws-sdk/middleware-host-header",
"@aws-sdk/config-resolver",
"@aws-sdk/s3-request-presigner",
"@aws-sdk/util-format-url",
"@aws-sdk/util-create-request",
"@aws-sdk/property-provider",
"axios",
"@aws-sdk/fetch-http-handler",
"@aws-sdk/protocol-http",
"@aws-sdk/querystring-builder",
"@aws-sdk/util-utf8-browser",
"@aws-sdk/url-parser-browser",
"@aws-crypto/sha256-browser",
"@aws-sdk/url-parser-node",
"@aws-sdk/util-uri-escape",
"@aws-sdk/middleware-sdk-s3",
"@aws-sdk/middleware-bucket-endpoint",
"@aws-sdk/querystring-parser",
"@aws-sdk/middleware-apply-body-checksum",
"@aws-sdk/middleware-ssec",
"@aws-sdk/middleware-expect-continue",
"fast-xml-parser",
"@aws-sdk/xml-builder",
"@aws-sdk/md5-js",
"@aws-sdk/hash-blob-browser",
"@aws-sdk/eventstream-serde-browser",
"@aws-sdk/middleware-location-constraint",
"uuid",
"@aws-sdk/credential-provider-cognito-identity",
"@aws-sdk/eventstream-serde-config-resolver",
"@aws-sdk/client-s3",
"@aws-sdk/client-pinpoint",
"ulid",
"zen-push",
"lodash",
"@aws-amplify/core",
"@aws-amplify/analytics",
"@aws-amplify/ui-components",
"isomorphic-unfetch"
]
in tsconfig.json as part of compilerOptions:
"paths": {
"crypto": [
"../../node_modules/crypto-js"
]
}
then there are no more warnings or errors.
Upvotes: 1