我正面臨着一個我無法解決的特定問題。我發現similar problems,但其解決方案不適合我。getDOM()爲null - 從Angular 2遷移到Angular 4
我正在將項目從Angular 2移動到Angular 4.我開始從零開始創建一個ng項目,使用最新的angular-cli,安裝所需的模塊並複製/粘貼我的舊項目結構。
這是app.module.ts
代碼:
@NgModule({
declarations: [
AppComponent,
HomeComponent,
LoginComponent,
SignupComponent,
ForgotComponent,
SelectBoxToDownloadFromGeoserverDialog,
ValidateTokenComponent,
ChangePasswordTokenComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
HttpModule,
ReCaptchaModule,
LoadingAnimateModule.forRoot(),
//MaterialModule,
RouterModule.forRoot(appRoutes, { useHash: true }),
MaterialModule
],
entryComponents : [LoginComponent, SignupComponent, ForgotComponent, SelectBoxToDownloadFromGeoserverDialog],
providers: [
LoadingAnimateService,
AuthService,
CanActivateAdmin,
{
provide: HighchartsStatic,
useFactory: highchartsFactory
}
],
bootstrap: [AppComponent]
})
export class AppModule { }
成功編譯後,我在瀏覽器接收到這個(怪異)錯誤:
Unhandled Promise rejection: getDOM(...) is null ; Zone: <root> ; Task: Promise.then ; Value: TypeError: getDOM(...) is null
Traza de la pila:
[email protected]://localhost:3000/vendor.bundle.js:94380:6
anonymous/AppModuleNgFactory</<@ng:///AppModule/module.ngfactory.js:119:58
[email protected]://localhost:3000/vendor.bundle.js:10123:26
[email protected]://localhost:3000/vendor.bundle.js:10052:26
[email protected]://localhost:3000/vendor.bundle.js:10003:13
[email protected]://localhost:3000/vendor.bundle.js:11111:9
[email protected]://localhost:3000/vendor.bundle.js:11095:12
[email protected]://localhost:3000/vendor.bundle.js:13379:12
[email protected]://localhost:3000/vendor.bundle.js:14374:16
PlatformRef_.prototype._bootstrapModuleFactoryWithZone/<@http://localhost:3000/vendor.bundle.js:5032:47
[email protected]://localhost:3000/polyfills.bundle.js:2758:17
[email protected]://localhost:3000/vendor.bundle.js:4409:28
[email protected]://localhost:3000/polyfills.bundle.js:2757:17
[email protected]://localhost:3000/polyfills.bundle.js:2508:24
[email protected]://localhost:3000/vendor.bundle.js:4277:51
[email protected]://localhost:3000/vendor.bundle.js:5030:16
PlatformRef_.prototype._bootstrapModuleWithZone/<@http://localhost:3000/vendor.bundle.js:5072:53
[email protected]://localhost:3000/polyfills.bundle.js:2758:17
[email protected]://localhost:3000/polyfills.bundle.js:2508:24
scheduleResolveOrReject/<@http://localhost:3000/polyfills.bundle.js:3185:52
[email protected]://localhost:3000/polyfills.bundle.js:2791:17
[email protected]://localhost:3000/polyfills.bundle.js:2558:28
[email protected]://localhost:3000/polyfills.bundle.js:2951:25
[email protected]://localhost:3000/vendor.bundle.js:94380:6
anonymous/AppModuleNgFactory</<@ng:///AppModule/module.ngfactory.js:119:58
[email protected]://localhost:3000/vendor.bundle.js:10123:26
[email protected]://localhost:3000/vendor.bundle.js:10052:26
[email protected]://localhost:3000/vendor.bundle.js:10003:13
[email protected]://localhost:3000/vendor.bundle.js:11111:9
[email protected]://localhost:3000/vendor.bundle.js:11095:12
[email protected]://localhost:3000/vendor.bundle.js:13379:12
[email protected]://localhost:3000/vendor.bundle.js:14374:16
PlatformRef_.prototype._bootstrapModuleFactoryWithZone/<@http://localhost:3000/vendor.bundle.js:5032:47
[email protected]://localhost:3000/polyfills.bundle.js:2758:17
[email protected]://localhost:3000/vendor.bundle.js:4409:28
[email protected]://localhost:3000/polyfills.bundle.js:2757:17
[email protected]://localhost:3000/polyfills.bundle.js:2508:24
[email protected]://localhost:3000/vendor.bundle.js:4277:51
[email protected]://localhost:3000/vendor.bundle.js:5030:16
PlatformRef_.prototype._bootstrapModuleWithZone/<@http://localhost:3000/vendor.bundle.js:5072:53
[email protected]://localhost:3000/polyfills.bundle.js:2758:17
[email protected]://localhost:3000/polyfills.bundle.js:2508:24
scheduleResolveOrReject/<@http://localhost:3000/polyfills.bundle.js:3185:52
[email protected]://localhost:3000/polyfills.bundle.js:2791:17
[email protected]://localhost:3000/polyfills.bundle.js:2558:28
[email protected]://localhost:3000/polyfills.bundle.js:2951:25
也許有幫助,這是我的package.json
:
{
"name": "test1",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/material": "^2.0.0-beta.6",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"angular-pipes": "^6.5.2",
"angular2-highcharts": "^0.5.5",
"angular2-recaptcha": "^0.6.0",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"jquery": "^3.2.1",
"ng2-ckeditor": "^1.1.8",
"ng2-dragula": "^1.5.0",
"ng2-loading-animate": "0.0.17",
"ng2-md-datatable": "^1.4.0",
"ng2-truncate": "^1.3.7",
"openlayers": "^4.2.0",
"proj4": "^2.4.3",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.0.6",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
我該如何解決這個錯誤,什麼是produci恩?
你在哪裏使用這個方法'getDOM()'? – Aravind
我沒有在代碼的任何部分使用getDOM()。也許第三方模塊正在使用它。我不知道。 –
它指向哪一行?你嘗試過調試嗎?或者你在teamviewer中可用? – Aravind