【问题标题】:VS2015: "Cannot find type definition" and "File not found" errorsVS2015:“找不到类型定义”和“找不到文件”错误
【发布时间】:2017-04-25 20:08:46
【问题描述】:

我有一个 Angular2 应用程序,直到两天前它都运行良好。当我尝试在 Visual Studio 2015 中构建解决方案时,出现 10 个错误:

Build: Cannot find type definition file for 'hammerjs'.
Build: Cannot find type definition file for 'jasmine'.
Build: File (...)/wwwroot/lib/ng2-translate/index.ts' not found.

还有 6 个关于 ng2-translate 中的各种文件未找到。

令人惊讶的是,当我通过 dotnet run 命令构建我的应用程序时,它运行良好。 我通过npm-check-updates -u 更新了所有内容,但并没有改变任何内容。 我的 package.json:

{
  "version": "1.0.0",
  "name": "CarMarket",
  "private": true,
  "dependencies": {
    "@angular/common": "~4.0.3",
    "@angular/compiler": "~4.0.3",
    "@angular/core": "~4.0.3",
    "@angular/forms": "~4.0.3",
    "@angular/http": "~4.0.3",
    "@angular/platform-browser": "~4.0.3",
    "@angular/platform-browser-dynamic": "~4.0.3",
    "@angular/router": "~4.0.3",
    "@angular/upgrade": "~4.0.3",
    "angular-in-memory-web-api": "~0.3.1",
    "body-parser": "1.17.1",
    "bootstrap": "3.3.7",
    "chart.js": "^2.5.0",
    "core-js": "^2.4.1",
    "es6-shim": "^0.35.0",
    "fancybox": "3.0.0",
    "jquery": "3.2.1",
    "ng2-charts": "^1.5.0",
    "ng2-translate": "^5.0.0",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.3.0",
    "systemjs": "0.20.12",
    "zone.js": "^0.8.9"
  },
  "devDependencies": {
    "@types/node": "^7.0.13",
    "del": "2.2.2",
    "gulp": "3.9.1",
    "gulp-typescript": "3.1.6",
    "gulp-watch": "4.3.11",
    "merge": "1.2.0",
    "typescript": "^2.0.10",
    "typings": "^2.1.1"
  },
  "scripts": {
    "postinstall": "typings install"
  }
}

这些错误的原因可能是什么? H

【问题讨论】:

    标签: visual-studio angular ng2-translate


    【解决方案1】:

    正如错误明确指出的那样,您缺少hammerjs 和jasmine 的类型定义。您可以将它们添加到您的类型定义文件中,也可以直接安装类型包:

    npm install --save @types/hammerjs
    npm install --save @types/jasmine
    

    【讨论】:

    • 我已经解决了,但这不是问题 - 实际上将 <TypeScriptCompileBlocked>True</TypeScriptCompileBlocked> 添加到 .xproj 使其工作。不过谢谢你的回答!
    • 不客气,很高兴你能自己解决这个问题!
    猜你喜欢
    • 2022-11-03
    • 2019-07-10
    • 2021-05-14
    • 1970-01-01
    • 2022-10-20
    • 2018-02-24
    • 2018-03-09
    • 2018-07-20
    • 2019-05-11
    相关资源
    最近更新 更多