Strange deployment error

While working on my next Ionic 2 article, I stumbled on a strange error.

Usually, while writing articles, I like to create a working example I can embed into it. This way my readers can play with provided code.

Unfortunately, Ionic 2 application architecture makes it impossible to import into the current Plunker (plnkr.co). I tried to deploy it on my local Windows Apache server, and everything worked just fine.

Then I moved it to my hosted Linux Apache server and at that point everything went to he**.

This is the link: http://example.gajotres.net/ionic2/example001/www/

I received this error:

EXCEPTION: Template parse errors:
Only void and foreign elements can be self closed "head" ("[ERROR ->]<head/><ion-nav id="nav" [root]="rootPage" swipe-back-enabled="false"></ion-nav>
"): MyApp@0:0

	STACKTRACE:BrowserDomAdapter.logError @ app.bundle.js:33679
	app.bundle.js:33679 Error: Template parse errors:
	Only void and foreign elements can be self closed "head" ("[ERROR ->]<head/><ion-nav id="nav" [root]="rootPage" swipe-back-enabled="false"></ion-nav>
	"): MyApp@0:0
		at new BaseException (app.bundle.js:7701)
		at TemplateNormalizer.normalizeLoadedTemplate (app.bundle.js:39564)
		at app.bundle.js:39553
		at Zone.run (app.bundle.js:1183)
		at Zone.run (app.bundle.js:17359)
		at zoneBoundFn (app.bundle.js:1156)
		at lib$es6$promise$$internal$$tryCatch (app.bundle.js:2556)
		at lib$es6$promise$$internal$$invokeCallback (app.bundle.js:2568)
		at lib$es6$promise$$internal$$publish (app.bundle.js:2539)
		at app.bundle.js:1288

Had anyone saw something similar?

I googled this error but can’t find anything even close resembling this error.

I believe it is being caused by <head> closing itself with the /. For example you can self close <img/> but you can’t self close a <div>. Angular added these errors in a recent release. Here’s the spec for void elements: http://www.w3.org/TR/html5/syntax.html#void-elements

2 Likes

Make sense, at least, provided error is pointing to that.

But, when I look at a content of my www folder, the head tag is not self-closed at any point. Furthermore, an application is working in Windows environment. I’m seeing this error only in Ubuntu.

Though I think I may have an idea. My Ubuntu based Apache uses Google Speed Mod plugin which, among other things, auto minifies everything. Maybe that is the cause of this problem.


After some testing I can confirm the problem was in Google mod_pagespeed plugin.

PS. Thanks @brandyshea you indirectly helped me brainstorm this problem :slight_smile:

1 Like

Good to know! I’m sure this thread will help someone out in the future. :smile: