Hi,
I got this error while trying to use : $ mjml -w index.mjml
[MJMLError] EmptyMJMLError : Null element found in mjmlElementParser
I try this one, and it's work without error : $> mjml -r index.mjml
I took this code for the test :
<mj-body>
<mj-section>
<mj-column>
<mj-text>Hi sexy!</mj-text>
</mj-column>
</mj-section>
</mj-body>
Version mjml : 1.2.1
Hey @JacquelinClement !
I can't manage to reproduce your error, do you have anything else that might have influenced the watch ?
Here is a screen of the complete error :

Maybe the vhost can affect the watch ?
It shouldn't. Basically, the watch is just a function that renders the file on each save. If the -r works the -w should work normally. What happens when you provide another code sample ?
Same code other commande :
$ mjml -r .clement.mjml -o clement.html

And watch with an other code (this code https://mjml.io/try-it-live/newsletter) into the file clement.mjml :
$ mjml -w clement.mjml

What version of Node are you using ?
Node version 4.3.2 :)
I just ran on the same issue. I have some mjml template rendering with the -w flag that first throws the following warning:
Warning: validateDOMNesting(...): <tr> cannot appear as a child of <td>. See Section > td > MJMLElement > MJMLColumnElement > tr.
And after that if I add an space anywhere I get the error
Error: [MJMLError] EmptyMJMLError: Null element found in mjmlElementParser
at MJMLError.Error (native)
at new MJMLError (/usr/lib/node_modules/mjml/lib/Error.js:24:85)
at Object.mjmlElementParser (/usr/lib/node_modules/mjml/lib/documentParser.js:24:13)
at documentParser (/usr/lib/node_modules/mjml/lib/documentParser.js:64:22)
at mjml2html (/usr/lib/node_modules/mjml/lib/mjml2html.js:49:52)
at /usr/lib/node_modules/mjml/lib/cli.js:81:12
I'm using node v0.12.10 btw
@llekn does it happen with the same MJML input file?
@arnaudbreton Yes, it happens with the same file. The first time I get the warning and if I add a space (in an irrelevant place of course, like between tags) MJML fails to compile it.
The funny thing is that erasing the space makes everything to work great again...
Can you confirm that's still happening on MJML 2 ?
Hi,
Just updated to mjml v2.0.0 and tried the example that @JacquelinClement gave, and got the following:
TypeError: Cannot read property 'length' of undefined
at documentParser (/usr/lib/node_modules/mjml/node_modules/mjml-core/lib/parsers/document.js:97:11)
at MJMLRenderer.parseDocument (/usr/lib/node_modules/mjml/node_modules/mjml-core/lib/MJMLRenderer.js:109:45)
at new MJMLRenderer (/usr/lib/node_modules/mjml/node_modules/mjml-core/lib/MJMLRenderer.js:76:12)
at /usr/lib/node_modules/mjml/node_modules/mjml-cli/lib/client.js:107:12
Am I doing something wrong? Using node v0.12.13 on Ubuntu 14.04 btw
Hi !
Can you try on node > 4 ?
Mmmm... Updated to node v4.4.3 and got the same error
Node v5.10.1
mjml v2.0.0
<mjml background-color="#F9F9F9">
<mj-body>
<mj-section>
<mj-text>abc</mj-text>
</mj-section>
</mj-body>
</mjml>
mjml -w input.mjml -o output.html
Warning: Please upgrade your MJML markup to add a <mjml> root tag, <mj-body> as root will no longer be supported soon, see https://github.com/mjmlio/mjml/UPGRADE.MD
TypeError: Cannot read property 'length' of undefined
at documentParser (/usr/local/lib/node_modules/mjml/node_modules/mjml-core/lib/parsers/document.js:97:11)
at MJMLRenderer.parseDocument (/usr/local/lib/node_modules/mjml/node_modules/mjml-core/lib/MJMLRenderer.js:109:45)
at new MJMLRenderer (/usr/local/lib/node_modules/mjml/node_modules/mjml-core/lib/MJMLRenderer.js:76:12)
at /usr/local/lib/node_modules/mjml/node_modules/mjml-cli/lib/client.js:107:12
Works normally in mjml v1.3.4
@gonchs you need an opening
We'll push a fix for mjml watch really soon, I belive this will fix your issue @gonchs ( don't forget to wrap you section with a mj-container
Can you test this in 2.0.2 ? Thanks !
Most helpful comment
Can you test this in
2.0.2? Thanks !