未捕获的类型错误:(0, tslib_1.__exportStar) 不是一个函数。

huangapple go评论88阅读模式
英文:

Uncaught TypeError: (0 , tslib_1.__exportStar) is not a function

问题

尝试将@aws-amplify/ui-angular添加到我的应用程序中,无论我尝试什么,都会出现这个错误。当我点击main.js时,就会显示出来。我已经尝试更改节点版本,升级和降级amplify/type script版本。

使用:

"typescript": "~4.8.4",
"@aws-amplify/ui-angular": "^4.0.1", // 也尝试了4.0.4
"aws-amplify": "^5.3.3",
/*!***********************************************************!*\
  !*** ./node_modules/@aws-crypto/sha256-js/build/index.js ***!
  \***********************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({
  value: true
}));
var tslib_1 = __webpack_require__(/*! tslib */ 29501);
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./jsSha256 */ 12008), exports);

(__webpack_require__(/*! ./jsSha256 */ 12008), exports); 这个是红色下划线的。

编辑:根据评论请求添加tsconfig.json

{
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  },
  "compileOnSave": false,
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": "./",
    "declaration": false,
    "downlevelIteration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "lib": [ "es2018", "dom", "esnext" ],
    "module": "esnext",
    "moduleResolution": "node",
    "outDir": "./dist/out-tsc",
    "paths": {
      "@core/*": [ "src/app/core/*" ],
      "@shared/*": [ "src/app/shared/*" ],
      "@services/*": [ "src/app/shared/services/*" ],
      "@enums/*": [ "src/app/types/enums/*" ],
      "@interfaces/*": [ "src/app/types/interfaces/*" ],
      "@mocks/*": [ "src/app/types/mocks/*" ],
      "@classes/*": [ "src/app/types/classes/*" ],

      // crypto browser warning fix...
      // https://stackoverflow.com/questions/54162297/module-not-found-error-cant-resolve-crypto
      "crypto": [
        "node_modules/crypto-js"
      ]
    },
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "target": "es2022",
    "typeRoots": [ "node_modules/@types" ],
    "useDefineForClassFields": false
  },
  "exclude": [
    "./amplify",
    "./config/**/*",
    "./coverage/**/*",
    "./dist",
    "./e2e",
    "./node_modules",
    "./scripts",
    ".serverless",
    ".webpack/**/*",
    "_warmup/**/*",
    ".vscode/**/*",
    ".idea/**/*",
    "commitlint.config.js",
    "aws-exports.js",
    "jest.config.js"
  ],
  "include": [
    "src/**/*.ts"
  ]
}
英文:

Trying to add @aws-amplify/ui-angular to my application and no matter what I try I get this error. When I click on main.js this is what shows up. I have tried changing node versions, upgrading and downgrading amplify/type script versions.

using:

"typescript": "~4.8.4"
"@aws-amplify/ui-angular": "^4.0.1", // tried 4.0.4 as well
"aws-amplify": "^5.3.3",
/*!***********************************************************!*\
  !*** ./node_modules/@aws-crypto/sha256-js/build/index.js ***!
  \***********************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({
  value: true
}));
var tslib_1 = __webpack_require__(/*! tslib */ 29501);
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./jsSha256 */ 12008), exports);

(__webpack_require__(/*! ./jsSha256 */ 12008), exports); this is red underlined

EDIT: adding tsconfig.json, per comment request

{
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  },
  "compileOnSave": false,
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": "./",
    "declaration": false,
    "downlevelIteration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "lib": [ "es2018", "dom", "esnext" ],
    "module": "esnext",
    "moduleResolution": "node",
    "outDir": "./dist/out-tsc",
    "paths": {
      "@core/*": [ "src/app/core/*" ],
      "@shared/*": [ "src/app/shared/*" ],
      "@services/*": [ "src/app/shared/services/*" ],
      "@enums/*": [ "src/app/types/enums/*" ],
      "@interfaces/*": [ "src/app/types/interfaces/*" ],
      "@mocks/*": [ "src/app/types/mocks/*" ],
      "@classes/*": [ "src/app/types/classes/*" ],

      // crypto browser warning fix...
      // https://stackoverflow.com/questions/54162297/module-not-found-error-cant-resolve-crypto
      "crypto": [
        "node_modules/crypto-js"
      ]
    },
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "target": "es2022",
    "typeRoots": [ "node_modules/@types" ],
    "useDefineForClassFields": false
  },
  "exclude": [
    "./amplify",
    "./config/**/*",
    "./coverage/**/*",
    "./dist",
    "./e2e",
    "./node_modules",
    "./scripts",
    ".serverless",
    ".webpack/**/*",
    "_warmup/**/*",
    ".vscode/**/*",
    ".idea/**/*",
    "commitlint.config.js",
    "aws-exports.js",
    "jest.config.js"
  ],
  "include": [
    "src/**/*.ts"
  ]
}

答案1

得分: 0

显然,我只是在我的tsconfig.json中指向了一个错误的tslib位置。删除它解决了这个问题。

英文:

Apparently I was simply pointing to an incorrect tslib location in my tsconfig.json. Removing it solved the issue.

huangapple
  • 本文由 发表于 2023年8月9日 01:03:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76861755.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定