【问题标题】:@types/async (DefinitelyTyped) errors when performing ng build执行 ng build 时出现@types/async (DefinitelyTyped) 错误
【发布时间】:2018-06-20 05:00:37
【问题描述】:

所以我们去年创建了一个网站:

  • 节点 v6.9.1
  • npm v3.10.8
  • angular-cli v1.0.0-beta.24
  • 打字稿 v2.1.4

此应用能够在上一个开发人员签入时构建。自从获得新开发人员、设置上述版本并执行 ng 构建后,我们现在遇到了新错误:

E:/code/score/node_modules/@types/async/index.d.ts (28,74) 中的错误:预期为“]”。 E:/code/score/node_modules/@types/async/index.d.ts (28,75) 中的错误:';'预期的。 E:/code/score/node_modules/@types/async/index.d.ts (28,76) 中的错误:需要声明或声明。 E:/code/score/node_modules/@types/async/index.d.ts (28,104) 中的错误:预期表达式。 E:/code/score/node_modules/@types/async/index.d.ts (29,120): ')' 中的错误。 E:/code/score/node_modules/@types/async/index.d.ts (29,155) 中的错误:'(' 预期。 E:/code/score/node_modules/@types/async/index.d.ts (28,62) 中的错误:计算的属性名称必须是“字符串”、“数字”、“符号”或“任意”类型'。 E:/code/score/node_modules/@types/async/index.d.ts (28,63) 中的错误:找不到名称“K”。 E:/code/score/node_modules/@types/async/index.d.ts (28,68) 中的错误:找不到名称“keyof”。 E:/code/score/node_modules/@types/async/index.d.ts (28,74) 中的错误:找不到名称“R”。 E:/code/score/node_modules/@types/async/index.d.ts (28,78) 中的错误:找不到名称“AsyncAutoTask”。 E:/code/score/node_modules/@types/async/index.d.ts (28,92) 中的错误:找不到名称“R”。 E:/code/score/node_modules/@types/async/index.d.ts (28,94) 中的错误:找不到名称“K”。 E:/code/score/node_modules/@types/async/index.d.ts (28,98) 中的错误:找不到名称“R”。 E:/code/score/node_modules/@types/async/index.d.ts (28,101) 中的错误:找不到名称“E”。 E:/code/score/node_modules/@types/async/index.d.ts (29,114) 中的错误:找不到名称“keyof”。 E:/code/score/node_modules/@types/async/index.d.ts (29,120) 中的错误:找不到名称“R”。 E:/code/score/node_modules/@types/async/index.d.ts (29,124) 中的错误:找不到名称“AsyncAutoTaskFunction”。`

这里是 package.json 的 dependencies 和 devDependencies 部分: "dependencies": { "@angular/common": "^2.3.1", "@angular/compiler": "^2.3.1", "@angular/core": "^2.3.1", "@angular/forms": "^2.3.1", "@angular/http": "^2.3.1", "@angular/platform-browser": "^2.3.1", "@angular/platform-browser-dynamic": "^2.3.1", "@angular/router": "^3.3.1", "@types/file-saver": "0.0.0", "angular2-apollo": "^0.9.0-rc.3", "apollo-client": "^0.7.1", "azure-storage": "^2.1.0", "bootstrap-sass": "^3.3.7", "chart.js": "^2.5.0", "core-js": "^2.4.1", "file-saver": "^1.3.3", "graphql-tag": "^1.2.2", "hammerjs": "^2.0.8", "jquery": "^3.1.1", "ng2-bootstrap": "^1.4.0", "ng2-charts": "^1.5.0", "ng2-cookies": "^1.0.8", "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", "zone.js": "^0.7.2" }, "devDependencies": { "@angular/compiler-cli": "^2.3.1", "@types/bootstrap": "^3.3.32", "@types/chai": "^3.4.34", "@types/isomorphic-fetch": "0.0.31", "@types/jasmine": "2.5.38", "@types/jquery": "^2.0.40", "@types/node": "^6.0.60", "angular-cli": "1.0.0-beta.24", "codelyzer": "~2.0.0-beta.1", "gulp": "3.9.1", "gulp-sourcemaps": "2.4.0", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", "protractor": "~4.0.13", "ts-node": "1.2.1", "tslint": "^4.0.2", "typed-graphql": "^1.0.2", "typescript": "~2.0.3" } 以下是 npm outdated 命令的输出: $ npm outdated Package Current Wanted Latest @angular/common 2.4.10 2.4.10 5.2.0 @angular/compiler 2.4.10 2.4.10 5.2.0 @angular/compiler-cli 2.4.10 2.4.10 5.2.0 @angular/core 2.4.10 2.4.10 5.2.0 @angular/forms 2.4.10 2.4.10 5.2.0 @angular/http 2.4.10 2.4.10 5.2.0 @angular/platform-browser 2.4.10 2.4.10 5.2.0 @angular/platform-browser-dynamic 2.4.10 2.4.10 5.2.0 @angular/router 3.4.10 3.4.10 5.2.0 @types/chai 3.5.2 3.5.2 4.1.0 @types/file-saver 0.0.0 0.0.0 1.3.0 @types/isomorphic-fetch 0.0.31 0.0.31 0.0.34 @types/jasmine 2.5.38 2.5.38 2.8.3 @types/jquery 2.0.48 2.0.48 3.2.17 @types/node 6.0.96 6.0.96 9.3.0 angular-cli 1.0.0-beta.24 1.0.0-beta.24 1.0.0-beta.28.3 apollo-client 0.7.3 0.7.3 2.2.0 codelyzer 2.0.1 2.0.1 4.0.2 graphql-tag 1.3.2 1.3.2 2.6.1 gulp-sourcemaps 2.4.0 2.4.0 2.6.3 jasmine-core 2.5.2 2.5.2 2.8.0 jasmine-spec-reporter 2.5.0 2.5.0 4.2.1 karma 1.2.0 1.2.0 2.0.0 karma-remap-istanbul 0.2.2 0.2.2 0.6.0 protractor 4.0.14 4.0.14 5.2.2 ts-node 1.2.1 1.2.1 4.1.0 tslint 4.5.1 4.5.1 5.9.1 typescript 2.0.10 2.0.10 2.6.2 zone.js 0.7.8 0.7.8 0.8.20

我们不确定如何解决这个问题,因为我们甚至尝试将 node/npm/angular/typescript 更新为其他问题。

任何帮助/指导/建议将不胜感激。

【问题讨论】:

  • 并非每个包的每个版本都与其他包的每个版本兼容。您需要深入研究每个文档,并弄清楚它的对等依赖项是什么以及它支持什么。包管理是一件痛苦的事情,因此必须非常小心和战略性地完成。您能否发布您的 package.json 文件中列出的依赖项和 devDependencies 以及可能在它失败的机器上的 npm outdated 的输出?
  • 你可以试试我在这个问题上的回答,看看对你有没有帮助stackoverflow.com/questions/48054005/…
  • 感谢@HT89,我最初尝试更新所有内容,但在整个工作代码中产生了更多不兼容问题。当我们撤下自上次成功部署以来工作且未更改的代码时,它只会给我们上面的错误。
  • 谢谢@mhodges,我已经编辑了问题以包含您想要查看的信息。
  • @JeffL8 我看到 typescript 2.0.10 列在你的 npm 过时输出中,但是你说你正在使用 2.1.4。你能为我澄清这个差异吗?此外,出于这个原因,将~^ 放在依赖项列表中是一个真的 坏主意,以供将来参考。每次npm install 时都不能保证包的版本相同,因此您可能会遇到版本冲突

标签: node.js angular typescript types definitelytyped


【解决方案1】:

所以在浏览了许多版本的 TypeScript(例如 2.0.10、2.1.4 和最新版本;2.6.2)之后,我们偶然发现了 2.1(没有修订,只是 major.minor: "typescript": "2.1")解决了构建。我们发现这很奇怪,但没有与之抗争,进行了更改,签入并看到 CI/CD 成功完成。

【讨论】:

    猜你喜欢
    • 2019-08-25
    • 1970-01-01
    • 2019-11-29
    • 1970-01-01
    • 2020-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    相关资源
    最近更新 更多