2016-11-16 16 views
0

昨日、NS NG2アプリで少し問題が発生しました。私はコマンドを実行しようとするたびに - tns livesync android - watch、または他のコマンドをビルドします。私は非常に長いエラーのリストを受け取ります。以下は、このエラーの小さなスニペットです。Typescript - すべてに重複する識別子

app/node_modules/typescript/lib/lib.es6.d.ts(20054,15): error TS2451: Cannot red 
eclare block-scoped variable 'name'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20328,6): error TS2300: Duplicate i 
dentifier 'AAGUID'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20329,6): error TS2300: Duplicate i 
dentifier 'AlgorithmIdentifier'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20330,6): error TS2300: Duplicate i 
dentifier 'ConstrainBoolean'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20331,6): error TS2300: Duplicate i 
dentifier 'ConstrainDOMString'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20332,6): error TS2300: Duplicate i 
dentifier 'ConstrainDouble'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20333,6): error TS2300: Duplicate i 
dentifier 'ConstrainLong'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20334,6): error TS2300: Duplicate i 
dentifier 'CryptoOperationData'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20335,6): error TS2300: Duplicate i 
dentifier 'GLbitfield'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20336,6): error TS2300: Duplicate i 
dentifier 'GLboolean'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20337,6): error TS2300: Duplicate i 
dentifier 'GLbyte'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20338,6): error TS2300: Duplicate i 
dentifier 'GLclampf'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20339,6): error TS2300: Duplicate i 
dentifier 'GLenum'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20340,6): error TS2300: Duplicate i 
dentifier 'GLfloat'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20341,6): error TS2300: Duplicate i 
dentifier 'GLint'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20342,6): error TS2300: Duplicate i 
dentifier 'GLintptr'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20343,6): error TS2300: Duplicate i 
dentifier 'GLshort'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20344,6): error TS2300: Duplicate i 
dentifier 'GLsizei'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20345,6): error TS2300: Duplicate i 
dentifier 'GLsizeiptr'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20346,6): error TS2300: Duplicate i 
dentifier 'GLubyte'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20347,6): error TS2300: Duplicate i 
dentifier 'GLuint'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20348,6): error TS2300: Duplicate i 
dentifier 'GLushort'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20349,6): error TS2300: Duplicate i 
dentifier 'IDBKeyPath'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20350,6): error TS2300: Duplicate i 
dentifier 'KeyFormat'. 
app/node_modules/typescript/lib/lib.es6.d.ts(20351,6): error TS2300: Duplicate i 
dentifier 'KeyType'. 

これは、私が受け取っているエラーのごくわずかなサンプルです。私がマックで仕事をしたときに起こったことは、私が予想以上のことをする必要があることを実感しました。私のPCに転送されるので、私ははるかにPCに精通しています。私は私が作った小さなコードの変更を引っ張って(すでにこれを逆にしようとした)、ビルドしようとしました。それが私がこのエラーリストに会った時です。答えを見つけるのに役立つかもしれない以下のファイルをいくつかリストアップします。

package.json

{ 
    "description": "AppName", 
    "license": "SEE LICENSE IN <your-license-filename>", 
    "readme": "AppName", 
    "repository": "myRepo", 
    "nativescript": { 
    "id": "org.nativescript.appName", 
    "tns-ios": { 
     "version": "2.4.0" 
    }, 
    "tns-android": { 
     "version": "2.4.0" 
    } 
    }, 
    "dependencies": { 
    "@angular/common": "2.1.2", 
    "@angular/compiler": "2.1.2", 
    "@angular/core": "2.1.2", 
    "@angular/forms": "2.1.2", 
    "@angular/http": "2.1.2", 
    "@angular/platform-browser": "2.1.2", 
    "@angular/platform-browser-dynamic": "2.1.2", 
    "@angular/platform-server": "^2.0.0", 
    "@angular/router": "3.1.2", 
    "email-validator": "^1.0.7", 
    "nativescript-angular": "1.1.3", 
    "nativescript-drop-down": "^1.3.3", 
    "nativescript-loading-indicator": "^2.2.1", 
    "nativescript-permissions": "^1.2.1", 
    "nativescript-plugin-firebase": "^3.7.1", 
    "nativescript-telerik-ui": "^1.4.1", 
    "nativescript-toasty": "^1.1.0", 
    "reflect-metadata": "~0.1.8", 
    "tns-core-modules": "2.4.0", 
    "tns-platform-declarations": "^2.0.0" 
    }, 
    "devDependencies": { 
    "babel-traverse": "6.19.0", 
    "babel-types": "6.19.0", 
    "babylon": "6.11.0", 
    "lazy": "1.0.11", 
    "filewalker": "0.1.2", 
    "nativescript-dev-typescript": "^0.3.2", 
    "typescript": "^2.0.10", 
    "zone.js": "~0.6.21" 
    } 
} 

references.d.ts

/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" /> Needed for autocompletion and compilation. 
/// <reference path="./node_modules/nativescript-plugin-firebase/index.d.ts" /> 
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.es6.d.ts" /> 

/// <reference path="./node_modules/tns-platform-declarations/ios/ios.d.ts" /> 
/// <reference path="./node_modules/tns-platform-declarations/android/android17.d.ts" /> 

/// <reference path="./node_modules/tns-platform-declarations/android/org.nativescript.widgets.d.ts" /> 

tsconfig.json

{ 
    "compilerOptions": { 
     "module": "commonjs", 
     "target": "es5", 
     "sourceMap": true, 
     "experimentalDecorators": true, 
     "emitDecoratorMetadata": true, 
     "noEmitHelpers": true, 
     "noEmitOnError": true, 
     "lib": [ 
      "es2016" 
     ] 
    }, 
    "exclude": [ 
     "node_modules", 
     "platforms" 
    ] 
} 

他のファイルがある場合、私はそれが聞かせください助けるかもしれ投稿することができます私は知っている。問題はこれらのファイルの1つにあると私は考えています。私は考えることができるすべてを試してみたが、アイデアはまったくない。うまくいけばあなたの一人のアイデアのいくつかの種類があります!おかげさまで

答えて

0

node_modules/typescript/lib/lib.es6.d.tsと他のファイル.d.tsへの参照が含まれているようです。私はあなたのpackage.jsonとtsconfig.jsonに基づいて新しく作成されたプロジェクトで同じエラーを再現しようとしましたが、私の設定にかかわらず、lib.es6.d.tsは決して蒸散に含まれていませんでした。

.d.tsファイルへの参照がすべてnode_modulesであることをすべてのファイルで確認する必要があります。それらのいくつかはお互いに矛盾しているように見えます。

また、node_modulesディレクトリを削除し、tns build androidを再度実行してみることもできます。

もう1つのメモ - tns-platform-declarationsはdevDependencyにする必要があります - 自動補完と蒸散のみに使用されていますが、デバイス上には必要ありません。

+0

問題を再現できなかったことに驚いています。今やりました。 tns create appname --ngを使用してプロジェクトを作成し、refファイルとpackageファイルに入れてください。全く同じ問題があります。しかし、私はこれらのファイルが原因で何が起こっているのか分かりませんでした。 –

0

あなたが含まれている参照のうちの1つが、es6の組み込みと競合しているes6の型をエクスポートしている可能性があります。

参照コメントを取り出して、重複する識別子の問題がまだあるかどうかを確認してください。

また、lib:["es6"]を取り出してみてください。他の何かが既にes6の入力をインポートしているからです。

新しいバージョンのtypescriptは、npmモジュールがエクスポートされている場合は、そのタイプをnpmモジュールから読み込むことができます。

compilerOptionsにmoduleResulotion: "node"を設定し、es6インポートを使用してプロジェクトのさまざまな部分に.d.tsファイルを読み込むことができます。

+0

エラーTS5023:不明なコンパイラオプション 'moduleResulotion'。あなたの最後のアイデアを試すとき –

0

が解決 -

だから、この問題を解決するために、私は私のpackage.jsonのすべての単一のラインを経て、各モジュールを見上げました。最近の更新を確認し、約20日前に最後に更新されたバージョンをインストールするように設定しました。それぞれについて。ノードモジュールを削除してnpmを4回インストールした後。出来た。

関連する問題