TypeError: Cannot read property 'replace' of null


#1

Hello!

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
(C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\logger\logger-diagnostics.js:187:77)
at generateDiagnosticHtml
(C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\logger\logger-diagnostics.js:179:12)
at Array.map (native)
at Object.printDiagnostics
(C:\dev\angular2\io-mobile\node_modules@ionic\app-scripts\dist\logger\logger-diagnostics.js:15:39)
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

System:

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

Misc:

backend : pro

#2

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


#3

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


#4

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:


#5

Hey Andrea,

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


#6

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


#7

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

“types”: [
“jasmine”
],

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