首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >amazon-cognito identity-js节点模块文件冲突

amazon-cognito identity-js节点模块文件冲突
EN

Stack Overflow用户
提问于 2020-10-02 11:29:13
回答 1查看 1.3K关注 0票数 1

我正在运行一个带有angular,amplify和cognito的应用程序。当我执行ng serve来运行应用程序时,我得到了这个错误。我试着删除了所有的节点模块,package-lock.json,但它没有改变任何东西,所以我想知道我应该做些什么来使它在执行ng服务时正常工作。

代码语言:javascript
复制
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.
EN

回答 1

Stack Overflow用户

发布于 2020-12-23 06:08:26

aws-amplify中不需要amazon-cognito-identity-js包。

代码语言:javascript
复制
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);

在angular.json中的.../build/options下:

代码语言:javascript
复制
        "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"
        ]

在tsconfig.json中,作为compilerOptions的一部分:

代码语言:javascript
复制
"paths": {
  "crypto": [
    "../../node_modules/crypto-js"
  ]
}

然后就不再有警告或错误了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64165838

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档