[Ivy] angular 9 compiler `Internal Error: The name <name> is already defined in scope to be [object Object]`
See original GitHub issue🐞 bug report
Affected Package
Is this a regression?
Yes, we’re migrating from 7.1.x, in 7’s version no error in aot mode
Description
if we accidentally duplicate let expression in template we’ll get an error
<ng-template #tmps let-obj let-obj="obj">
{{obj | json}}
</ng-template>
<ng-container
[ngTemplateOutlet]="tmps"
[ngTemplateOutletContext]="{$implicit: {a: 2}"
</ng-container>
this is correct behavior, but during migration it’s quite hard to investigate where actually error is.
Cause of error message The name <name> is already defined in scope to be [object Object]
due to [object Object] it’s not understandable
Minimal Reproduction
https://github.com/djleonskennedy/ng9-repro
npm inpm run build --prod
NOTE - issue cannot be reproduced in stackblitz
🔥 Exception or Error
ERROR in Error: Internal Error: The name obj is already defined in scope to be [object Object]
at error (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:2721:15)
at BindingScope.set (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:18154:17)
at TemplateDefinitionBuilder.registerContextVariables (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:17051:32)
at /home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:16967:59
at Array.forEach (<anonymous>)
at TemplateDefinitionBuilder.buildTemplateFunction (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:16967:23)
at /home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:17558:60
at /home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:16992:81
at Array.forEach (<anonymous>)
at TemplateDefinitionBuilder.buildTemplateFunction (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:16992:37)
at Object.compileComponentFromMetadata (/home/project/src/santander/misc/example/node_modules/@angular/compiler/bundles/compiler.umd.js:18643:58)
at ComponentDecoratorHandler.compile (/home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/component.js:534:34)
at _loop_2 (/home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:542:53)
at TraitCompiler.compile (/home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:572:21)
at IvyVisitor.visitClassDeclaration (/home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/transform.js:51:40)
at /home/project/src/santander/misc/example/node_modules/@angular/compiler-cli/src/ngtsc/util/src/visitor.js:77:93
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! example@0.0.0 build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the example@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/yuriy_yakovenko/.npm/_logs/2020-02-12T10_41_09_828Z-debug.log
🌍 Your Environment
Angular Version:
Angular CLI: 9.0.1
Node: 12.13.1
OS: linux x64
Angular: 9.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.1
@angular-devkit/build-angular 0.900.1
@angular-devkit/build-optimizer 0.900.1
@angular-devkit/build-webpack 0.900.1
@angular-devkit/core 9.0.1
@angular-devkit/schematics 9.0.1
@angular/cli 9.0.1
@ngtools/webpack 9.0.1
@schematics/angular 9.0.1
@schematics/update 0.900.1
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Anything else relevant? Could be related: https://github.com/angular/angular-cli/issues/14663
Regards Yuriy!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Internal Error: The name element is already defined in ...
Error : The name element is already defined in scope to be [object Object], here check for name variable. Share.
Read more >Upgrade Angular from 8 to 9 #9932
5.000 What is your product type (Angular or MVC... ... ERROR in Error: Internal Error: The name i is already defined in scope...
Read more >Error codes - CKEditor 5 Documentation
Error codes. CKEditor 5 Framework logs errors and warnings to the console. The following list contains more detailed descriptions of those issues.
Read more >All About Angular Engine Ivy in 5 mins
To compile a component in Ivy, Angular only needs information about the component itself, except for the name and package name of its ......
Read more >Angular Ivy
To revert the compiler default, set the build option aot: false in the angular.json configuration file. If you disable Ivy and the project...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@kavindraD you’re declaring the variable
itwice.Try changing it to
After a week … I managed to solve this problem. I changed the <names> of the variables in NgFor. In my case, the variable was ‘i’