gpt4 book ai didi

angular - 无法重新声明 block 作用域变量 'ngDevMode'

转载 作者:太空狗 更新时间:2023-10-29 16:53:09 26 4
gpt4 key购买 nike

我的应用在 Angular 5 上。这是 package.json 的样子

{
"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

npm install angular-io-datepicker --save

现在,当我执行 ng serve 时(在 app.module.ts 中包含 OverlayModule 和 DatePickerModule 之后),它给了我以下错误

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,这个模块仍然给我同样的问题。

最佳答案

我遇到了同样的错误,尽管我认为这是由对位于不同项目中的 Typescript 文件的引用引起的。我能够按照此处的建议解决问题:github issues 24165 .具体来说,我将以下内容添加到项目根目录中 tsconfig.json 文件的 compilerOptions 中:

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

注意:如果您的基本路径不为空,则可能需要使用 ../node_modules

关于angular - 无法重新声明 block 作用域变量 'ngDevMode',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48926322/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com