Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

839
Views
Cannot redeclare block-scoped variable 'ngDevMode'

My app in on Angular 5. Here is how the package.json looks like

{
  "name": "myapp",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@types/file-saver": "0.0.1",
    "angular-2-dropdown-multiselect": "^1.6.0",
    "angular2-csv": "^0.2.5",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "file-saver": "^1.3.3",
    "ngx-bootstrap": "^1.9.3",
    "ngx-clipboard": "^8.1.0",
    "ngx-loading": "^1.0.14",
    "ngx-pagination": "^3.0.0",
    "ngx-toastr": "^6.4.0",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "~1.7.0",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }
}

Everything is fine so far. Now I need to use a datepicker in my app. So I installed angular-io-datepicker

npm install angular-io-datepicker --save

Now, when I do a ng serve (after including the OverlayModule and DatePickerModule in app.module.ts ), it gives me the below error

ERROR in node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
node_modules/angular-io-overlay/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.

Any suggestions on what could be wrong and how to fix it? I was earlier using this module successfully with Angular 4. Then I upgraded to Angular 5 and it broke. Now even if I rollback to angular 4, this module still gives me the same problem.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

I ran into the same error, although I think it was caused by a reference to a Typescript file located in a different project. I was able to resolve the problem by following the advice here: github issues 24165. Specifically, I added the following to the compilerOptions in the tsconfig.json file in the root of my project:

"paths": {
  "@angular/*": ["node_modules/@angular/*"]
}

Note: it may be necessary to use ../node_modules if your base path is not empty.

over 4 years ago · Santiago Trujillo Report

0

For angular 6 in tsConfig

if the baseUrl is src then setting the path as follows works.

"paths": {
            "@angular/*": [
                "../node_modules/@angular/*"
            ]`enter code here`
        },

if the baseUrl is empty then setting the path without root worked for me

"paths": {
            "@angular/*": [
                "node_modules/@angular/*"
            ]
        },
over 4 years ago · Santiago Trujillo Report

0

i can see correct answer is already given ,But i think better explanation is needed whats happening with the answer.

in tsconfig.json

 "paths": {

 "@angular/*": ["node_modules/@angular/*"]
}

this tells the compiler to choose "node_modules/@angular", the angular version of main application's for all the occurrences including libraries

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!