ng服务后重复的标识符

时间:2017-07-17 12:28:40

标签: webpack angular-cli

当我在本地计算机上尝试ng serve时,我无法编译项目。我使用angular-cli。我有很多错误,上面写着Duplicate Identifierscannot redeclare

ERROR in C:/dev/src/functions/node_modules/@types/node/index.d.ts (1719,10): Duplicate identifier 'AsyncCompleter'
ERROR in C:/dev/src/functions/node_modules/@types/node/index.d.ts (2866,22): Cannot redeclare block-scoped variable 'F_OK'.
ERROR in C:/dev/src/functions/node_modules/base64url/typings/globals/node/index.d.ts (57,5): Subsequent variable declarations must have the same type.  Variable 'parent' must be of type 'NodeModule', but here has type 'any'.

等等。列表继续。我很困惑我的项目发生了什么。 这是我的package.json

{
  "name": "gri-data-gathering",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.1.3",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/material": "^2.0.0-beta.6",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@google-cloud/storage": "^1.1.1",
    "@swimlane/ngx-datatable": "^9.2.0",
    "angularfire2": "^4.0.0-rc.0",
    "child-process-promise": "^2.2.1",
    "core-js": "^2.4.1",
    "firebase": "^3.6.6",
    "hammerjs": "^2.0.8",
    "ng2-handsontable": "^1.0.3",
    "ng2-md-datatable": "^1.3.13",
    "nodemailer": "^4.0.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.3",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  }
}

这是tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "baseUrl": "",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

我一直在阅读有关此类行为的博客和文档,但没有运气,找不到任何解决方案。请帮帮我,谢谢。

1 个答案:

答案 0 :(得分:0)

我修复了一个类似的问题,解决方法是在项目文件夹中执行:

npm remove typescript --save-dev && npm install typescript@2.1 --save-dev