Error: Illegal State: referring to a type without a variable

when i run : ionic serve it works fine ,

but when i run : ionic serve --prod , i get an error

[ng] ERROR in Illegal State: referring to a type without a variable {“filePath”:“C:/Users/nacer/Desktop/BridgeDz2/node_modules/@angular/router/router.d.ts”,“name”:“RouterLink”,“members”:}

Help please.

helloo !!!
can anyone help please?

Hi,
Do you got any solution for this error? I am also facing similar error message while --prod.

My error message is
“ERROR in Illegal State: referring to a type without a variable {“filePath”:”/src/app/directives/ext-lnk.ts",“name”:“ExtLnkDirective”,“members”:}"

Please help.

Thanks,
Zack

I found solution to my error which is similar to yours. Thanks to @simon at https://ionicacademy.com/

Basically, some modules/components are including multiple times. Your error might be due to similar problem, please go through this answer on stackflow

this error can be caused by components being registered in multiple modules, for example in  `app.module`  and  `my_feature_module.module` .

**Temporarily**  disabling  `tsconfig.json -> fullTemplateTypeCheck`  and re-running  `ng build --prod`  might show the related component registration errors.
1 Like

Thank you so much bro , it did work .