错误TS2688 Build:找不到' mocha'的类型定义文件打字稿更新后

时间:2017-09-10 03:37:00

标签: asp.net visual-studio angular typescript asp.net-core

我,我一直收到错误:当我将打字稿更新到最新版本时,无法找到' mocha' 的类型定义文件。

tsconfig.json

    {
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "sourceMap": true,
    "suppressImplicitAnyIndexErrors": true,
    "target": "es5",
    "rootDir": "app",
    "outDir": "wwwroot/app"
  },
  "exclude": [
    "node_modules",
    "wwwroot/node_modules",
    "typings"

  ]
}

我,没有改变任何事情。它只是更早地工作,我将打字稿版本从2.2.2更新到2.5并继续收到错误。我,我正在使用角4

的package.json

    {
  "version": "1.0.0",
  "name": "asp.net",
  "private": true,
  "dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/compiler-cli": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/platform-server": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@angular/upgrade": "2.0.0",
    "angular2-in-memory-web-api": "0.0.20",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.9",
    "rxjs": "5.0.2",
    "systemjs": "0.19.27",
    "typescript": "^2.4.1",
    "zone.js": "0.7.6"
  },
  "devDependencies": {}
}

请有人告诉我如何解决此问题。

3 个答案:

答案 0 :(得分:2)

您需要为mocha安装类型定义。

修复

npm install @types/mocha

答案 1 :(得分:0)

如果您使用的是纱线卷装管理器:

yarn add --dev mocha

答案 2 :(得分:0)

这是@nestjs/microservice上的一个问题,已修复将其升级到6.5.1 请检查问题here