我在我的NS NG2应用程序上遇到了一些问题。每当我尝试运行命令tns livesync android --watch或任何其他要构建的命令时,我都会收到一个非常长的错误列表。下面是这个错误的一个小片段。
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'.这只是我收到的误差的一个很小的样本。
当我在我的mac电脑上工作,然后转到我的电脑上时,这就发生了。我提取了我所做的小代码更改(已经尝试过反转这些代码)并试图构建。这时我遇到了这个错误列表。下面我将列出几个可能有助于找到答案的文件。
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"
]
}发布于 2016-11-17 16:22:55
为了解决这个问题,我遍历了我的package.json的每一行并查找了每个模块。检查他们最近的更新,并将其设置为安装20天前更新的版本。每个人都是。在删除我的节点模块并执行4次npm install之后,它成功了。
发布于 2016-11-16 22:40:37
看起来,其他一些文件包含了对node_modules/typescript/lib/lib.es6.d.ts和其他.d.ts文件的引用。我尝试复制同样的错误,使用基于您的package.json和tsconfig.json的新创建的项目,但是无论我的配置如何,lib.es6.d.ts从未包含在传输溢出中。
您应该检查所有文件是否引用node_modules中的node_modules文件。看上去他们中的一些人互相冲突。
此外,您还可以尝试删除node_modules目录并再次执行tns build android。
还有一个注意事项-- tns-platform-declarations应该是devDependency --它只用于自动完成和传输溢出,您不需要在设备上使用它。
发布于 2016-11-16 22:43:28
您所包含的引用之一可能是导出es6类型,这与内置的es6类型相冲突。
取出引用注释,看看是否仍然存在重复的标识符问题。
还可以尝试删除lib:" es6“,因为其他东西已经在导入es6类型。
新版本的类型记录可以从npm模块加载类型,如果它们是导出的话。
可以在moduleResulotion: "node"中设置compilerOptions,并使用es6导入将.d.ts文件加载到项目的不同部分。
https://stackoverflow.com/questions/40642218
复制相似问题