Solvedangular error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'
✔️Accepted Answer
Other Answers:
Ran into the same issue today, in my case the problem is one of my libraries that had a direct dependency on @angular/core
.
When installing my library in the actual ng-project it also created a node_modules folder there so I had two versions of @angular/core
in the project - and both declare ngDevMode in the global scope resulting in the error message described in this issue.
I was actually just running into this very same problem. I created a library with ng-packagr. I then used npm link to include this into a brand new angular/cli project (angular ^5.0.0).
As soon as I included the module from my library, I got this compilation error. The said library is massive, so including that one here wouldn't be feasible. I'll see if I can knock out a bare library and see if it still has same end result. Maybe its angular mismatch, as my library targets angular 4+
I'm having the same problem with 5.2.1.
For me, downgrading to 5.1.3 solved it for now.
npm install @angular/common@5.1.3 @angular/compiler@5.1.3 @angular/compiler-cli@5.1.3 @angular/core@5.1.3 @angular/forms@5.1.3 @angular/http@5.1.3 @angular/platform-browser@5.1.3 @angular/platform-browser-dynamic@5.1.3 @angular/platform-server@5.1.3 @angular/router@5.1.3 @angular/animations@5.1.3 --save
Angular 7, same issue after upgrading from Angular 6 with ng update
I'm submitting a...
Current behavior
node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
node_modules/adv-view-js-comp-core/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
declare global {
const ngDevMode: boolean;
}
export declare const _ngDevMode: boolean;
export {};
Expected behavior
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment