VS2015构建失败“重复标识符”Angular 2

时间:2017-06-06 15:44:59

标签: visual-studio angular typescript typescript-typings

安装和卸载angular-cli之后,我的构建失败并出现此错误:

1>...\node_modules\@types\jasmine\index.d.ts(9,18): error TS2300: Build:Duplicate identifier 'describe'. 1>...\node_modules\@types\jasmine\index.d.ts(11,18): error TS2300: Build:Duplicate identifier 'xdescribe'. 1>...\node_modules\@types\jasmine\index.d.ts(13,18): error TS2300: Build:Duplicate identifier 'it'. 1>...\node_modules\@types\jasmine\index.d.ts(15,18): error TS2300: Build:Duplicate identifier 'xit'. 1>...\node_modules\@types\mocha\index.d.ts(33,13): error TS2300: Build:Duplicate identifier 'describe'. 1>...\node_modules\@types\mocha\index.d.ts(34,13): error TS2300: Build:Duplicate identifier 'xdescribe'. 1>...\node_modules\@types\mocha\index.d.ts(39,13): error TS2300: Build:Duplicate identifier 'it'. 1>...\node_modules\@types\mocha\index.d.ts(40,13): error TS2300: Build:Duplicate identifier 'xit'.

此刻解决方案非常混乱,我是Angular 2 / TypeScript的新手,因此调试非常困难。我尝试了这个解决方案Typescript, confusing "duplicate identifier" error message,但它对我不起作用。

tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "*": [ "./node_modules/@types/*", "*" ]
     },
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "types": [ ],
     "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "/node_modules",
    "../node_modules",
    "*node_modules*",
    "/node_modules*",
    "angular2",
    "rxjs",
    "typings"
  ]
}

1 个答案:

答案 0 :(得分:1)

看起来像.d.ts定义冲突。您同时使用JasmineMocha吗?如果没有,请删除您未使用的文件夹,然后删除node_modules文件夹并再次运行npm install