我最近将现有的Angular 6应用程序升级到了Angular7。我的大多数应用程序都基于Angular 6构建,然后我对其进行了升级。
这是我的package.json:
{
"name": "app-name",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.5",
"@angular/animations": "^7.0.0",
"@angular/cdk": "^7.0.0",
"@angular/common": "^7.0.0",
"@angular/compiler": "^7.0.0",
"@angular/core": "^7.0.0",
"@angular/fire": "^5.0.2",
"@angular/forms": "^7.0.0",
"@angular/http": "^7.0.0",
"@angular/material": "^7.0.0",
"@angular/platform-browser": "^7.0.0",
"@angular/platform-browser-dynamic": "^7.0.0",
"@angular/router": "^7.0.0",
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"firebase": "^5.5.1",
"npm": "^6.4.1",
"rxjs": "^6.3.3",
"sweetalert2": "^7.28.7",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.8",
"@angular/cli": "~7.0.2",
"@angular/compiler-cli": "^7.0.0",
"@angular/language-service": "^7.0.0",
"@types/googlemaps": "^3.30.13",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~3.1.3"
}
}
这是我在运行ng build --prod
时收到的警告:
C:\Development\Angular\MyApp>ng build --prod
Date: 2018-10-24T17:36:28.367Z
Hash: a03e526b7e8175b25c06
Time: 32695ms
chunk {0} 0.cafd68819f30185de9af.js () 74.8 kB [rendered]
chunk {1} 1.00224f689303f6e8aae8.js () 33.7 kB [rendered]
chunk {2} 2.c9d485747518d5177cf8.js () 29.7 kB [rendered]
chunk {3} 3.e25546a8136eb13e9af3.js () 31.5 kB [rendered]
chunk {4} 4.120580aa06e187956a3a.js () 51.3 kB [rendered]
chunk {5} 5.890208a2f9c910b04821.js () 62.8 kB [rendered]
chunk {6} 6.659eb84df5c798c5ff39.js () 29.4 kB [rendered]
chunk {7} runtime.4ee86023cc00ae14666e.js (runtime) 1.99 kB [entry] [rendered]
chunk {8} styles.f6067b501f9d2a5208bf.css (styles) 215 kB [initial] [rendered]
chunk {9} polyfills.644a401562606166b860.js (polyfills) 59.6 kB [initial] [rendered]chunk {10} main.be4cab576441165d61f9.js (main) 1.13 MB [initial] [rendered]
WARNING in ./src/app/tv/components/add-program-card/add-program-card.component.ngfactory.js
31:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i2') was not found in '@angular/forms'
WARNING in ./src/app/tv/components/edit-program-card/edit-program-card.component.ngfactory.js
31:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i2') was not found in '@angular/forms'
WARNING in ./src/app/news/components/edit-article-card/edit-article-card.component.ngfactory.js
33:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i2') was not found in '@angular/forms'
WARNING in ./src/app/news/components/add-news-card/add-news-card.component.ngfactory.js
33:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i2') was not found in '@angular/forms'
WARNING in ./src/app/team/components/add-player-card/add-player-card.component.ngfactory.js
33:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i2') was not found in '@angular/forms'
WARNING in ./src/app/team/components/edit-player-card/edit-player-card.component.ngfactory.js
33:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i2') was not found in '@angular/forms'
WARNING in ./src/app/boutique/components/add-merchandise-card/add-merchandise-card.component.ngfactory.js
39:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i6') was not found in '@angular/forms'
WARNING in ./src/app/boutique/components/edit-merchandise-card/edit-merchandise-card.component.ngfactory.js
39:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i6') was not found in '@angular/forms'
WARNING in ./src/app/games/components/edit-game-card/edit-game-card.component.ngfactory.js
45:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i2') was not found in '@angular/forms'
WARNING in ./src/app/games/components/add-game-card/add-game-card.component.ngfactory.js
45:52-87 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i2') was not found in '@angular/forms'
WARNING in ./src/app/components/login/login.component.ngfactory.js
49:53-88 "export 'ɵangular_packages_forms_forms_bh' (imported as 'i5') was not found in '@angular/forms'
最初我不太喜欢这些警告。但是,当我尝试导航到Firebase Hosting上托管的应用程序时,我的应用程序未加载,并且在控制台上也出现此错误:
Uncaught TypeError: e is not a constructor
at main.be4cab576441165d61f9.js:1
at Xr (main.be4cab576441165d61f9.js:1)
at main.be4cab576441165d61f9.js:1
at new t (main.be4cab576441165d61f9.js:1)
at Object.mi [as createNgModuleRef] (main.be4cab576441165d61f9.js:1)
at e.create (main.be4cab576441165d61f9.js:1)
at main.be4cab576441165d61f9.js:1
at e.invoke (polyfills.644a401562606166b860.js:1)
at Object.onInvoke (main.be4cab576441165d61f9.js:1)
at e.invoke (polyfills.644a401562606166b860.js:1)
到目前为止我已经尝试过的事情:
搜索了ɵangular_packages_forms_forms_bh
,发现它在angular/forms-builds/bundles/forms.umd.min.js.map
中被引用,并被更新了约20分钟。以前,但不知道该怎么做。
在此 GitHub Issue 中发现了类似的问题,该问题指向 this comment ,但看起来与我的无关错误。它表明我需要从src/index.ts
导出所有我目前没有的东西。
有人可以向我指出正确的方向,如何解决此错误吗?
我在实现SharedModule
的{{1}}中创建了一个自定义表单控件元素。这是相同的模板:
ControlValueAccessor
这些警告与此有关吗?
答案 0 :(得分:2)
从Angular 6升级到Angular 7后,我有相同的警告和错误。 我已删除我的 node_modules 文件夹,然后再次 npm install 。 现在,编译成功完成,没有警告,而且我也没有错误“ Uncaught TypeError:e不是构造函数” 。