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

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

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

问题

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

使用:

  1. "typescript": "~4.8.4",
  2. "@aws-amplify/ui-angular": "^4.0.1", // 也尝试了4.0.4
  3. "aws-amplify": "^5.3.3",
  1. /*!***********************************************************!*\
  2. !*** ./node_modules/@aws-crypto/sha256-js/build/index.js ***!
  3. \***********************************************************/
  4. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5. "use strict";
  6. Object.defineProperty(exports, "__esModule", ({
  7. value: true
  8. }));
  9. var tslib_1 = __webpack_require__(/*! tslib */ 29501);
  10. (0, tslib_1.__exportStar)(__webpack_require__(/*! ./jsSha256 */ 12008), exports);

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

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

  1. {
  2. "angularCompilerOptions": {
  3. "fullTemplateTypeCheck": true,
  4. "strictInjectionParameters": true
  5. },
  6. "compileOnSave": false,
  7. "compilerOptions": {
  8. "allowJs": true,
  9. "allowSyntheticDefaultImports": true,
  10. "baseUrl": "./",
  11. "declaration": false,
  12. "downlevelIteration": true,
  13. "emitDecoratorMetadata": true,
  14. "experimentalDecorators": true,
  15. "importHelpers": true,
  16. "lib": [ "es2018", "dom", "esnext" ],
  17. "module": "esnext",
  18. "moduleResolution": "node",
  19. "outDir": "./dist/out-tsc",
  20. "paths": {
  21. "@core/*": [ "src/app/core/*" ],
  22. "@shared/*": [ "src/app/shared/*" ],
  23. "@services/*": [ "src/app/shared/services/*" ],
  24. "@enums/*": [ "src/app/types/enums/*" ],
  25. "@interfaces/*": [ "src/app/types/interfaces/*" ],
  26. "@mocks/*": [ "src/app/types/mocks/*" ],
  27. "@classes/*": [ "src/app/types/classes/*" ],
  28. // crypto browser warning fix...
  29. // https://stackoverflow.com/questions/54162297/module-not-found-error-cant-resolve-crypto
  30. "crypto": [
  31. "node_modules/crypto-js"
  32. ]
  33. },
  34. "resolveJsonModule": true,
  35. "skipLibCheck": true,
  36. "sourceMap": true,
  37. "target": "es2022",
  38. "typeRoots": [ "node_modules/@types" ],
  39. "useDefineForClassFields": false
  40. },
  41. "exclude": [
  42. "./amplify",
  43. "./config/**/*",
  44. "./coverage/**/*",
  45. "./dist",
  46. "./e2e",
  47. "./node_modules",
  48. "./scripts",
  49. ".serverless",
  50. ".webpack/**/*",
  51. "_warmup/**/*",
  52. ".vscode/**/*",
  53. ".idea/**/*",
  54. "commitlint.config.js",
  55. "aws-exports.js",
  56. "jest.config.js"
  57. ],
  58. "include": [
  59. "src/**/*.ts"
  60. ]
  61. }
英文:

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:

  1. "typescript": "~4.8.4"
  2. "@aws-amplify/ui-angular": "^4.0.1", // tried 4.0.4 as well
  3. "aws-amplify": "^5.3.3",
  1. /*!***********************************************************!*\
  2. !*** ./node_modules/@aws-crypto/sha256-js/build/index.js ***!
  3. \***********************************************************/
  4. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5. "use strict";
  6. Object.defineProperty(exports, "__esModule", ({
  7. value: true
  8. }));
  9. var tslib_1 = __webpack_require__(/*! tslib */ 29501);
  10. (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

  1. {
  2. "angularCompilerOptions": {
  3. "fullTemplateTypeCheck": true,
  4. "strictInjectionParameters": true
  5. },
  6. "compileOnSave": false,
  7. "compilerOptions": {
  8. "allowJs": true,
  9. "allowSyntheticDefaultImports": true,
  10. "baseUrl": "./",
  11. "declaration": false,
  12. "downlevelIteration": true,
  13. "emitDecoratorMetadata": true,
  14. "experimentalDecorators": true,
  15. "importHelpers": true,
  16. "lib": [ "es2018", "dom", "esnext" ],
  17. "module": "esnext",
  18. "moduleResolution": "node",
  19. "outDir": "./dist/out-tsc",
  20. "paths": {
  21. "@core/*": [ "src/app/core/*" ],
  22. "@shared/*": [ "src/app/shared/*" ],
  23. "@services/*": [ "src/app/shared/services/*" ],
  24. "@enums/*": [ "src/app/types/enums/*" ],
  25. "@interfaces/*": [ "src/app/types/interfaces/*" ],
  26. "@mocks/*": [ "src/app/types/mocks/*" ],
  27. "@classes/*": [ "src/app/types/classes/*" ],
  28. // crypto browser warning fix...
  29. // https://stackoverflow.com/questions/54162297/module-not-found-error-cant-resolve-crypto
  30. "crypto": [
  31. "node_modules/crypto-js"
  32. ]
  33. },
  34. "resolveJsonModule": true,
  35. "skipLibCheck": true,
  36. "sourceMap": true,
  37. "target": "es2022",
  38. "typeRoots": [ "node_modules/@types" ],
  39. "useDefineForClassFields": false
  40. },
  41. "exclude": [
  42. "./amplify",
  43. "./config/**/*",
  44. "./coverage/**/*",
  45. "./dist",
  46. "./e2e",
  47. "./node_modules",
  48. "./scripts",
  49. ".serverless",
  50. ".webpack/**/*",
  51. "_warmup/**/*",
  52. ".vscode/**/*",
  53. ".idea/**/*",
  54. "commitlint.config.js",
  55. "aws-exports.js",
  56. "jest.config.js"
  57. ],
  58. "include": [
  59. "src/**/*.ts"
  60. ]
  61. }

答案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:

确定