mjml: TypeError: Cannot read property 'replace' of undefined
Describe the bug
After install the package with the command npm install -g mjml, and run a simple file only with mj-section mj-column mj-text, the following error show:
➜ mjml index.mjml
File: index.mjml
TypeError: Cannot read property 'replace' of undefined
Command line error:
Input file(s) failed to render
PS: the version of mjml 4.7.1 is working.
To Reproduce Steps to reproduce the behavior:
- With node version 12.19.0 and npm version 6.14.8 install globally the mjml
npm install -g mjml. - Create a file with this MJML code:
<mj-section>
<mj-column>
<mj-text> Some text </mj-text>
</mj-column>
</mj-section>
- Render it to HTML by running:
mjml index.mjml - See error
Expected behavior A clear and concise description of what you expected to happen.
MJML environment (please complete the following information):
- OS: MacOS Catalina 10.15.7
- MJML Version 4.8.2
- MJML tool used: MJML CLI
Email sending environment(for rendering issues):
- Platform used to send the email [e.g Putsmail]
Affected email clients (for rendering issues):
- Email Client [e.g Gmail]
- OS: [e.g. Windows]
- Browser [e.g. Google Chrome]
Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (8 by maintainers)
Hi, i think it’s related to the fact that there is no
<mjml>and<mj-body>tags in your mjmlSorry folks, looks like this was user error. After to speaking to another dev on our team we realised that I was using
fs.readFileSyncto ingest the MJML file, but I wasn’t specifying an encoding, so it was returning an object, not a string.This was broken:
This worked:
cc @kmcb777 We might need to handle this behavior in MJML5 where rendering without any dep registered would crash because of empty content returned by
processingmethod