【问题标题】:./node_modules/@types/lodash/common/object.d.ts (1689,12): Cannot find name 'Exclude'./node_modules/@types/lodash/common/object.d.ts (1689,12):找不到名称“排除”
【发布时间】:2019-09-17 11:05:25
【问题描述】:

我有一个在我的 mac osx Mojave 上工作的项目的开发环境。但是,由于内存 RAM 问题,我决定降级到 ma osx High Sierra。现在,我正在尝试再次部署该项目,但我面临以下问题


node_modules/@types/lodash/common/object.d.ts(1689,12): error TS2304: Cannot find name 'Exclude'.

1689         ): Exclude<TObject[TKey], undefined> | TDefault;

这是尝试编译此部分的脚本的一部分:tsc ./src/app/+charts/index.ts --outFile ./shared/charts.js --module amd --pretty。因此,它使用全局 Typescript 来编译它。我已经在全球范围内安装了 3.4、2.6 和 2.8 版本,但在所有这些版本中我都遇到了相同的错误。另外,这个项目的正确节点版本是8,所以我用的是8.16.0(这是我在格式化电脑之前使用的版本)。

这是我的 package.json

"dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/cdk": "^5.1.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/material": "^5.1.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/platform-server": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@covalent/core": "1.0.0",
    "@covalent/dynamic-forms": "1.0.0",
    "@covalent/highlight": "1.0.0",
    "@covalent/http": "1.0.0",
    "@covalent/markdown": "1.0.0",
    "@covalent/text-editor": "1.0.0",
    "@ngx-translate/core": "^8.0.0",
    "@ngx-translate/http-loader": "^2.0.0",
    "@swimlane/ngx-charts": "^7.0.1",
    "@types/d3": "^5.0.0",
    "angular2-text-mask": "^9.0.0",
    "core-js": "^2.4.1",
    "cors": "^2.8.4",
    "d3": "^4.9.0",
    "d3-format": "^1.2.0",
    "exceljs": "^0.5.1",
    "hammerjs": "^2.0.8",
    "highlight.js": "9.10.0",
    "html-pdf": "^2.1.0",
    "libphonenumber-js": "1.0.24",
    "lodash": "^4.17.4",
    "moment": "2.21.0",
    "moment-range": "3.1.1",
    "ngx-currency": "^1.1.2",
    "nodemon": "^1.11.0",
    "requirejs": "^2.3.6",
    "rxjs": "^5.5.6",
    "showdown": "1.6.4",
    "web-animations-js": "2.2.5",
    "webshot": "^0.18.0",
    "zone.js": "^0.8.20"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.3",
    "@angular/compiler-cli": "^5.2.0",
    "@types/hammerjs": "2.0.30",
    "@types/jasmine": "2.5.38",
    "@types/lodash": "^4.14.110",
    "@types/node": "~6.0.60",
    "@types/selenium-webdriver": "2.53.36",
    "codelyzer": "~4.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.3.0",
    "karma-jasmine": "^1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.4",
    "karma-remap-istanbul": "^0.6.0",
    "karma-spec-reporter": "^0.0.31",
    "phantomjs-prebuilt": "2.1.14",
    "prepend-file": "^1.3.1",
    "protractor": "~5.1.0",
    "ts-node": "3.1.0",
    "tslint": "^5.2.0",
    "typescript": "~2.6.2",
    "watch": "^1.0.2"
  },

我也尝试将"@types/lodash": "^4.14.110", 更改为"@types/lodash": "^4.14.121",,但这也没有用。而且,我不确定更改 package.json 中的任何内容是否有意义,因为在我格式化计算机并降级操作系统之前,这个项目工作正常

那么,我在这里缺少什么?我将不胜感激任何帮助。提前致谢

【问题讨论】:

    标签: angular typescript lodash


    【解决方案1】:

    似乎是@types/lodash 的问题,您可以在此处查找问题:https://github.com/DefinitelyTyped/DefinitelyTyped/issues/33778

    解决办法好像是downgrade @types/lodash to

    npm i -D @types/lodash@ts2.5
    

    or updating typescript

    typescript@~2.8
    

    【讨论】:

      猜你喜欢
      • 2020-03-27
      • 2020-12-21
      • 2018-11-04
      • 2021-07-12
      • 2019-11-25
      • 1970-01-01
      • 2018-07-25
      • 2019-07-27
      • 1970-01-01
      相关资源
      最近更新 更多