2
votes

I'm using ngx translate for translation in my ionic 4 project. But when i try to run:

ionic cordova build android -prod

Throws this error:

ERROR in Illegal State: referring to a type without a variable {"filePath":"C:/XXX/XXX/XXX/XXX/PROJECTNAME/node_modules/@ngx-translate/core/ngx-translate-core.d.ts","name":"TranslatePipe","members":[]}

[ERROR] An error occurred while running subprocess ng

My ionic info:

Ionic:

Ionic CLI : 5.2.7 (C:\Users\USER\AppData\Roaming\npm\node_modules\ionic) Ionic Framework : @ionic/angular 4.9.0 @angular-devkit/build-angular : 0.801.3 @angular-devkit/schematics : 8.1.3 @angular/cli : 8.1.3 @ionic/angular-toolkit : 2.0.0

Cordova:

Cordova CLI : 9.0.0 ([email protected]) Cordova Platforms : not available Cordova Plugins : not available

Utility:

cordova-res : 0.6.0 native-run : 0.2.8

System:

Android SDK Tools : 26.1.1 (C:\Users\USER\AppData\Local\Android\Sdk) NodeJS : v12.5.0 (C:\Program Files\nodejs\node.exe) npm : 6.9.0 OS : Windows 10

Please help!!!

3

3 Answers

-2
votes

you do not need to write -prod because it converts the file into minified version so device to hard to read. u just need run without -prod

ionic cordova build android

if you want a release APK just run

ionic cordova build android --release

after that, u do not face any issue.

0
votes

The accepted answer is a solution to avoid the problem, but when a production build is needed, things are looking bad.

Workaround to achieve this is to access your tsconfig.json and disable fullTemplateTypeCheck to false. Include it, if you can not find it.

"angularCompilerOptions": {
    "fullTemplateTypeCheck": false,
    ...
},
0
votes

This error actually means that a reference failure is present among your components and modules. That could be a dupliate reference in a module or and submodule or any the like. This would result in ommiting to make a needed variable available. In your case that is the variable of ngx-translate (which your either call in the template or component file).

Setting the fullTemplateTypeCheck to false will help you to get the insights (including code line) about your false module references. But you must fix it yourself. Usually an easy fix. If you are uncertain, run again ng build --prod --verbose to see get more indications about the false relations.