Issue
I ran into a bit of an issue with my NS NG2 app. Whenever I try to run the command tns livesync android --watch
, or any other command to build, I receive a very long list of errors. Below is a small snippet of this error.
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'.
This is just a very small sample of the errors I am receiving.
This happened when I went to work on my mac and then transferred to my PC. I pulled the small code changes I made (have already tried to reverse these) and tried to build. That is when I was met with this error list. I am going to list a few files below that may help in finding the answer.
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"
]
}
Solution
To solve this issue, I went through every single line of my package.json and looked up each module. Checked for their recent updates and set it to install a version last updated about 20 days ago. For each one. After deleting my node modules and doing npm install
4 times, it worked.
Answered By - Sam R
Answer Checked By - Katrina (JavaFixing Volunteer)