无法重新声明块作用域变量"ngDevMode" [英] Cannot redeclare block-scoped variable 'ngDevMode'
问题描述
我的应用程序位于Angular 5上.这是package.json的样子
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"
}
}
到目前为止一切都很好.现在,我需要在应用程序中使用日期选择器.所以我安装了angular-io-datepicker
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
现在,当我进行ng服务时(在App.module.ts中包括OverlayModule和DatePickerModule之后),它给了我以下错误
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'.
关于可能出什么问题以及如何解决的任何建议?我之前在Angular 4中成功使用了此模块.然后我升级到了Angular 5,但它坏了.现在,即使我回滚到angular 4,该模块仍然会给我带来同样的问题.
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.
推荐答案
我遇到了相同的错误,尽管我认为这是由于引用了位于不同项目中的Typescript文件引起的.我可以按照以下建议解决问题: github问题24165 .具体来说,我在项目根目录的tsconfig.json
文件的compilerOptions
中添加了以下内容:
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/*"]
}
注意:如果您的基本路径不为空,则可能需要使用../node_modules
.
Note: it may be necessary to use ../node_modules
if your base path is not empty.
这篇关于无法重新声明块作用域变量"ngDevMode"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!