2017-07-17 103 views
0

當我在本地機器上嘗試ng serve時,我無法編譯我的項目。我使用angular-cli。我有一大堆,說Duplicate Identifierscannot redeclareng服務後的重複標識符

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" 
    ] 
} 

我一直在閱讀博客和文檔關於這種行爲,但沒有運氣,找不到任何解決辦法。請幫助我,謝謝。

回答

0

我固定一個類似的問題,有一種變通方法,在項目文件夾執行:

npm remove typescript --save-dev && npm install [email protected] --save-dev