Unexpected value 'HTMLImageElement' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation

Hi
i am getting this issue while running ionic serve
i got this problem when i deleted some of the code which i am not using and deleted it from the app.module.ts file also
Earlier it was working fine

import { BrowserModule } from ‘@angular/platform-browser’;
import { NgModule, ErrorHandler } from ‘@angular/core’;
import { IonicApp, IonicModule, IonicErrorHandler } from ‘ionic-angular’;
import { MyApp } from ‘./app.component’;

//import { ItemDetailsPage } from ‘…/pages/item-details/item-details’;

import { ListPage } from ‘…/pages/list/list’;
import { ContactPage } from ‘…/pages/contact-page/contact-page’;
import { AboutPage } from ‘…/pages/about-page/about-page’;
import { AngularPage } from ‘…/pages/angular-page/angular-page’;
import { Angular2Page } from ‘…/pages/angular2-page/angular2-page’;
import { Rewrite } from ‘…/pages/rewrite/rewrite’;
import { Sample } from ‘…/pages/sample/sample’;
import { Enviornment } from ‘…/pages/enviornment/enviornment’;
import { Http } from ‘…/pages/http/http’;
import { Decorator } from ‘…/pages/decorator/decorator’;
import { Routing } from ‘…/pages/routing/routing’;
import { Ngmodule } from ‘…/pages/ngmodule/ngmodule’;
import { Template } from ‘…/pages/template/template’;

import { Dependency } from ‘…/pages/dependency/dependency’;
import { Guards } from ‘…/pages/guards/guards’;
import { Observables } from ‘…/pages/observables/observables’;
import { Installation } from ‘…/pages/installation/installation’;

import { IonicImageViewerModule } from ‘ionic-img-viewer’;

import { StatusBar } from ‘@ionic-native/status-bar’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;

@NgModule({
declarations: [
MyApp,
// ItemDetailsPage,
ListPage,
ContactPage,
AboutPage,
AngularPage,
Angular2Page,
Rewrite,
Sample,
Enviornment,
Http,
Decorator,
Routing,
Ngmodule,
Template,
Image,
Dependency,
Guards,
Observables,
Installation
],
imports: [
BrowserModule,
IonicImageViewerModule,
IonicModule.forRoot(MyApp),
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
// ItemDetailsPage,
ListPage,
ContactPage,
AboutPage,
AngularPage,
Angular2Page,
Rewrite,
Sample,
Enviornment,
Http,
Decorator,
Routing,
Ngmodule,
Template,
Image,
Dependency,
Guards,
Observables,
Installation

],
providers: [
StatusBar,
SplashScreen,
HTMLImageElement,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
This is my app.module file

Have you added a @Pipe, @Directive, or a @Component decorator to HTMLImageElement?

HTMLImageElement is declared in the dom library. I find creating things with that clash with stuff in standard libraries is a recipe for pain, because my IDE has no way of knowing that I need an import for them. Assuming it’s something you created, I’d rename it (ditto for Decorator and Http). If it’s supposed to be the actual DOM class, get it out of providers. You don’t provide that.

I think your life would also become easier if you named your pages more consistently, instead of some of them having Page and some not.

will i get solution…if i will create a new project and add this code into the new one…with page at end

You still haven’t explained what you are trying to do with HTMLInputElement.

i am not using HTMLInputElement anywhere in my code.

Sorry, I misspoke. I meant HTMLImageElement.

No…i am not using HTMLImageElement anywhere.
not in my module file, not in my page, not in overall project.
My code was running, after complition the code i just deleted some of my pages that i am not using and deleted the iport part as well as declaration and after this issue is coming

It seems to be listed in the providers stanza of your app module as posted above. Are you saying you took that out? If so, it’s mysterious that it would be mentioned in an error as described in the topic headline.

No it was not in the provider…it was not in the list earlier also.

Do you not see it in this post?

no…it was not earlier

I’m confused. Are you saying that gremlins edited your post, or am I misreading what you wrote? I clearly see:

providers: [
StatusBar,
SplashScreen,
HTMLImageElement,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]

oh sorry…i pasted it wrong the HTMLImageElement was not there…i just wrote it when i was debugging sorry for this
but the issue is same

I’m sorry, but I have a very difficult time believing you get an error referencing HTMLImageElement (as is in the topic headline) when you have removed every single reference to that class in your code.

Hi @rapropos…Thanks for your support
i am unable to find the issue.so i created a new project and paste this code in that
Now it’s working fine.
Thanks again :slight_smile:

1 Like

@rapropos can u check one of my issue