【问题标题】:Angular 2 RC.5 & VS 2015: Cannot find name 'module', 'Set', 'Map', 'MapConstructor', 'SetConstructor'Angular 2 RC.5 和 VS 2015:找不到名称“模块”、“设置”、“地图”、“地图构造器”、“设置构造器”
【发布时间】:2017-01-08 09:57:17
【问题描述】:

我遇到的问题在标题中。我读过的所有内容都说这是一个打字问题,但我还没有找到它。这是一个相当大的项目,所以我只举几个我的设置示例:

tsconfig.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
"exclude": ["node_modules", "typings"]
}

typings.json

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160602141332",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160807145350"
  }
}

package.json

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/compiler-cli": "0.5.0",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.5",
    "angular2-in-memory-web-api": "0.0.17",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.2.0",
    "typescript": "^1.8.10",
    "typings":"^1.3.3"
  }
}

我尝试过的事情:

  1. 直接在我的应用入口点引用类型文件
  2. 更改 compilerOptions -> 目标为 es6/es2015
  3. 卸载并重新安装根目录中的类型引用
  4. 将 typings.json 更新到最新版本
  5. 安装 es6-shim 及其类型

任何其他建议将不胜感激。

【问题讨论】:

  • 看来你使用的是VS 2015,你检查过VISUAL STUDIO 2015 QUICKSTART Guide吗?
  • 是的,我在设置项目时专门遵循它。这是项目成功工作数月后的最新问题(过去 2 天)。
  • 不是您问题的答案,只是分享我的经验。我使用了 Visual Studio,但因为我使用了 vscode,所以我再也不想回到我的前端项目中了。更快更好的前端开发

标签: angular typescript typescript-typings


【解决方案1】:

差点忘了这个问题……

我通过从项目中删除 nuget 包 Typescript.Compiler 和 Typescript.MsBuild 解决了这个问题。

【讨论】:

    【解决方案2】:

    你上面的package.json 有"typescript":"^1.8.10",但如果你在最后一两天更新到2.0.2,它可能是this bug 和Typescript。如果是这样,降级到早期版本应该可以解决它。

    您的错误消息看起来与 angular-cli 上 this issue 中报告的错误消息非常相似 项目。

    【讨论】:

      猜你喜欢
      • 2011-10-13
      • 2014-10-20
      • 2017-01-17
      • 2014-11-03
      • 2014-01-18
      • 1970-01-01
      • 1970-01-01
      • 2021-11-23
      • 2014-07-24
      相关资源
      最近更新 更多