【问题标题】:Error TS2688 Build:Cannot find type definition file for 'mocha' after TypeScript update错误 TS2688 构建:TypeScript 更新后找不到“mocha”的类型定义文件
【发布时间】:2018-02-18 14:17:35
【问题描述】:

当我将 TypeScript 更新到最新版本时,我不断收到 错误:找不到“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"

  ]
}

我,没有改变任何东西。之前它工作得很好,只是我将 TypeScript 版本从 2.2.2 更新到 2.5 并不断出错。我,正在使用 Angular 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": {}
}

【问题讨论】:

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


    【解决方案1】:

    这是@nestjs/microservice 的问题,升级到6.5.1 时已修复 请查看问题here

    【讨论】:

      【解决方案2】:

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

      npm install @types/mocha
      

      【讨论】:

      • 我应该在哪里安装这种类型。是在全局还是到项目的特定文件夹\
      • 没有解决这个问题 - 找不到“mocha”的类型定义文件
      • 它修复了一个问题并在@jest 中给出了以下附加错误
      【解决方案3】:

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

      yarn add --dev mocha
      

      【讨论】:

        猜你喜欢
        • 2018-02-24
        • 2017-09-08
        • 2019-07-10
        • 2021-05-14
        • 1970-01-01
        • 2022-10-20
        • 2018-03-09
        • 2019-05-11
        • 2018-07-23
        相关资源
        最近更新 更多