Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error ''Identifier 'territoryFromName' has already been declared" on AOT build with Angular & Kendo UI

Very recently, and without any version change to our package, our AOT build failed with this error message :

ERROR in chunk vendor [initial] [name].bundle.js Identifier
'territoryFromName' has already been declared (13:9)
}

function territoryFromName(name, identity) { var likelySubtags = __WEBPACK_MODULE_REFERENCE__7_636c6472__.supplemental.likelySubtags; var parts = name.split("-");

Our package.json file looks like this :

{
  "name": "frontend",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "build": "webpack --config webpack.config.js",
    "build:Production": "npm run fixmem && webpack --config webpack.config.prod.js --env.Production",
    "build:test": "webpack --config webpack.config.testAOT.js",
    "fixmem": "node increase-webpack-memory.js"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "5.2.5",
    "@angular/common": "5.2.5",
    "@angular/compiler": "5.2.5",
    "@angular/core": "5.2.5",
    "@angular/forms": "5.2.5",
    "@angular/http": "5.2.5",
    "@angular/platform-browser": "5.2.5",
    "@angular/platform-browser-dynamic": "5.2.5",
    "@angular/platform-server": "5.2.5",
    "@angular/router": "5.2.5",
    "@progress/kendo-angular-buttons": "4.1.2",
    "@progress/kendo-angular-dateinputs": "3.4.4",
    "@progress/kendo-angular-dialog": "3.6.2",
    "@progress/kendo-angular-dropdowns": "3.0.2",
    "@progress/kendo-angular-excel-export": "2.1.1",
    "@progress/kendo-angular-grid": "3.5.1",
    "@progress/kendo-angular-inputs": "3.2.0",
    "@progress/kendo-angular-intl": "1.4.1",
    "@progress/kendo-angular-l10n": "1.2.0",
    "@progress/kendo-angular-layout": "3.1.1",
    "@progress/kendo-angular-popup": "2.4.1",
    "@progress/kendo-angular-tooltip": "0.4",
    "@progress/kendo-angular-upload": "4.1.4",
    "@progress/kendo-data-query": "1.4.0",
    "@progress/kendo-drawing": "1.5.6",
    "@progress/kendo-ui": "2018.2.704",
    "@progress/telerik-angular-report-viewer": "3.18.125",
    "@telerik/kendo-intl": "1.3.2",
    "angular-tree-component": "7.1.0",
    "babel-polyfill": "6.9.1",
    "bootstrap": "4.0.0",
    "es6-shim": "0.35.3",
    "jquery": "3.2.1",
    "moment": "2.18.1",
    "moment-timezone": "0.5.13",
    "oidc-client": "1.4.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.5.6",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@angular-devkit/core": "0.3.2",
    "@angular/cli": "1.7.4",
    "@angular/compiler-cli": "5.2.5",
    "@angular/language-service": "5.2.0",
    "@ngtools/webpack": "1.10.2",
    "@progress/kendo-theme-default": "2.54.0",
    "@types/jasmine": "2.8.3",
    "@types/jasminewd2": "2.0.2",
    "@types/node": "6.0.60",
    "aspnet-webpack": "3.0.0",
    "autoprefixer": "7.2.6",
    "circular-dependency-plugin": "4.4.0",
    "codelyzer": "4.0.1",
    "copy-webpack-plugin": "4.4.3",
    "cross-env": "5.0.5",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.11",
    "font-awesome": "4.7.0",
    "html-webpack-plugin": "2.30.1",
    "istanbul-instrumenter-loader": "3.0.1",
    "less-loader": "4.1.0",
    "npm-font-open-sans": "1.0.3",
    "popper.js": "1.14.3",
    "postcss-import": "11.1.0",
    "postcss-loader": "2.1.6",
    "postcss-url": "7.3.2",
    "raw-loader": "0.5.1",
    "rxjs-tslint": "0.1.5",
    "rxjs-tslint-rules": "4.7.2",
    "sass-loader": "6.0.7",
    "style-loader": "0.19.1",
    "stylus-loader": "3.0.2",
    "ts-node": "4.1.0",
    "tslint": "5.9.1",
    "tslint-clean-code": "0.2.3",
    "tslint-consistent-codestyle": "1.11.1",
    "tslint-eslint-rules": "5.0.0",
    "tslint-sonarts": "1.4.0",
    "typescript": "2.4.2",
    "uglifyjs-webpack-plugin": "1.2.7",
    "url-loader": "0.6.2",
    "webpack": "3.11.0",
    "webpack-cli": "3.0.8",
    "webpack-dev-server": "2.11.2"
  }
}

We always refresh the node_modules folder (nuke + npm install) before any build, and the error showed up very recently (around last Monday 2018-08-29).

We haven't done any changes in the package versions since the last builds.

The build without AOT still works fine without any error.

How to fix this error ?

like image 451
Pac0 Avatar asked Aug 29 '18 08:08

Pac0


3 Answers

I also ran into this error. I did not explicitly have @telerik/kendo-intl installed in my package.json. It was being installed as a dependency for @progress/kendo-angular-intl at version @1.4.1.

I npm installed @telerik/kendo-intl to the latest version @1.4.2 and this resolved my error. @Nour - If you look at the difference between @1.4.1 and @1.4.2 you will noticed that the Kendo team removed the duplicate declaration.

like image 87
Rod Avatar answered Oct 17 '22 00:10

Rod


I have been digging to find what's wrong with my application since I haven't done any recent updates, and yet still facing this error !

Inside the file: \node_modules\@telerik\kendo-intl\dist\es\cldr\territory.js

there is a duplicate declaration of the function territoryFromName one with just name as a parameter and the other one has two parameters name & identity

The first one has no use and I just removed it from the file and saved it and it worked just fine.

PS. I believe they would fix this bug very soon, but for now this worked for me.

like image 32
Nour Avatar answered Oct 16 '22 23:10

Nour


Just delete this line from the package.json file :

"@telerik/kendo-intl": "1.3.2",

After some research, we found that territoryFromName was defined in the kendo-intl related modules.

There seems to be some dependency confusion in the kendo packages, and it looks like the @telerik package was only redefining dependencies from the @progress kendo-angular more recent packages.

From what I understand, this has come in conflict with our @progress/kendo-angular-intl package

like image 1
Pac0 Avatar answered Oct 17 '22 00:10

Pac0