TypeError: Cannot read property 'replace' of null


I’m having the following error when trying to build or run my ionic app:
TypeError: Cannot read property ‘replace’ of null

I’ve searched and there seem to be a few people having a similar issue but none of the fixes I’ve tried so far have worked.

The strange thing that when I build it using the Ionic Pro it seems to work fine, it just takes ~18 seconds to load the app so I was looking to build it locally with the --prod tag to get it load faster.

Any help would be much appreciated.

Some further informaton:

ionic cordova build android --verbose produces:

[DEBUG] TypeError: Cannot read property ‘replace’ of null
at Object.escapeHtml (C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\util\helpers.js:251:9)
at generateCodeBlock
at generateDiagnosticHtml
at Array.map (native)
at Object.printDiagnostics
at C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\transpile.js:136:34
at transpileWorker (C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\transpile.js:103:12)
at Object.transpile (C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\transpile.js:61:12)
at buildProject (C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\build.js:97:78)
at C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\build.js:47:16

[15:56:11] copy finished in 6.00 s
[DEBUG] registerShutdownFunction process.exit/normal shutdown

ionic info:

cli packages: (C:\dev\angular2\io-mobile\node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.3.0 browser 4.1.0
Ionic Framework    : ionic-angular 3.6.0


Android SDK Tools : 26.1.1
Node              : v6.11.1
npm               : 5.1.0
OS                : Windows 10

Environment Variables:

ANDROID_HOME : C:\Users\David\AppData\Local\Android\sdk1


backend : pro

I’m a paid user. Is there any way to get support for this issue?

Hi, i heave the same issue on windows 7. Suggestions?

Hello @omniwoof, can you provide some code so I or anyone else can have idea where you are facing the problem. Problem might be in code where you are trying to read some property of an element which might not have loaded yet or something :confused:

Hey Andrea,

It turned out to be a typings issue, try updating the typings and you should be right.

Can you please provide some example of how to do it? Thanks

This can be related to ‘jasmin’ typings. If you are not going to run tests in the project then just remove

“types”: [

from tsconfig.json. This should help build the app.