构建:更新为角度4后,无法在tsc文件中找到“mocha”的类型定义文件

时间:2017-05-10 08:43:49

标签: angular

我正在将当前的项目版本更新为Angular 4.我收到的错误如Build:Cannot Find type definition file for 'mocha' in tsc file

我使用以下步骤更新了项目。

  1. npm install @ angular / common @ latest @ angular / compiler @ latest @ angular / compiler-cli @ latest @ angular / core @ latest @ angular / forms @ latest @ angular / http @ latest @ angular / platform -browser @ latest @ angular / platform-b​​rowser-dynamic @ latest @ angular / platform-server @ latest @ angular / router @ latest @ angular / animations @ latest typescript @ latest --save

  2. 将stypescript版本更新为2.3.1

  3. 我正在使用Visual Studio 2015 Update 3。

    这是我的package.json文件

    {
      "name": "angular-quickstart",
      "version": "1.0.0",
      "scripts": {
        "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
        "lite": "lite-server",
        "postinstall": "typings install",
        "tsc": "tsc",
        "tsc:w": "tsc -w",
        "typings": "typings",
        "build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js"
      },
      "licenses": [
        {
          "type": "MIT",
          "url": "https://github.com/angular/angular.io/blob/master/LICENSE"
        }
      ],
      "dependencies": {
        "@angular/animations": "^4.0.0",
        "@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": "~4.1.1",
        "angular-in-memory-web-api": "~0.3.2",
        "bootstrap": "^3.3.7",
        "core-js": "^2.4.1",
        "mocha": "^3.1.2",
        "reflect-metadata": "^0.1.8",
        "rxjs": "^5.0.1",
        "systemjs": "0.20.12",
        "typescript": "^2.3.1",
        "typings": "^1.5.0",
        "zone.js": "^0.8.10"
      },
      "devDependencies": {
        "@angular/compiler-cli": "^4.0.0",
        "concurrently": "^3.0.0",
        "lite-server": "^2.2.2",
        "rollup": "^0.41.4",
        "rollup-plugin-commonjs": "^8.0.2",
        "rollup-plugin-node-resolve": "^3.0.0",
        "rollup-plugin-uglify": "^1.0.1",
        "typescript": "^2.2.0-dev.20170207",
        "typings": "^2.1.1"
      }
    }
    

1 个答案:

答案 0 :(得分:0)

我认为你所看到的是Visual Studio正在尝试在编译时为你构建你的打字稿,但是从你的npm脚本中不知道你的单独构建过程。如果你有另一个编译过程,我认为你可以放心地禁用这个功能,如本文所述:http://rostacik.net/2015/08/14/how-to-disable-building-of-typescript-files-in-visual-studio-2015/

重要的步骤是: 添加节点

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

到第一个

<PropertyGroup>
.csproj文件中的

元素。