Error ''Identifier 'territoryFromName' has already been declared" on AOT build with Angular & Kendo UI
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("-");
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 ?
3 Answers
3
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.
Welcome to Stack Overflow, and excellent to have nailed down the exact version for the correction.
– Pac0
Aug 31 '18 at 5:45
Actually I have installed it using
ng add
not using regular npm install
– Nour
Aug 31 '18 at 16:29
ng add
npm install
You may have meant v1.4.1 and v1.4.2 ?! Did the trick for me too
– J.Starkl
Sep 4 '18 at 9:18
@J.Starkl thank you for the comment! I updated my answer to the correct versions!
– Rod
Sep 13 '18 at 13:29
Important to note, that you probably have to remove
@progress/kendo-angular-intl
and re add it as soon as you have @telerik/kendo-intl
installed– Tienou
Mar 1 at 12:12
@progress/kendo-angular-intl
@telerik/kendo-intl
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@telerikkendo-intldistescldrterritory.js
node_modules@telerikkendo-intldistescldrterritory.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
territoryFromName
name
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.
Thank you for your diggin for the exact cause and for the "home-made" fix ! As per Rod's answer, this is fixed in
@kendo-angular-intl
4.1.2, so maybe it's already fixed as well in a recent update of @telerik-intl
.– Pac0
Aug 31 '18 at 5:44
@kendo-angular-intl
@telerik-intl
This was the issue for me as well. Deleted the function with only a single arg.
– Sean Chase
Oct 24 '18 at 22:38
Just delete this line from the package.json
file :
package.json
"@telerik/kendo-intl": "1.3.2",
After some research, we found that territoryFromName
was defined in the kendo-intl related modules.
territoryFromName
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
@progress/kendo-angular-intl
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I'm writing a self-answerd Q&A, but feel free to add an answer as well if you know how to solve it in a different way, or with more information on Why this could have happened, apparently out of nowhere for me.
– Pac0
Aug 29 '18 at 8:46