TypeError: Cannot read property 'replace' of undefined
See original GitHub issueDescribe 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (8 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'replace' of Undefined in JS
The "Cannot read property 'replace' of undefined" error occurs when calling the replace() method on a variable that stores an undefined value. To...
Read more >Cannot read property 'replace' of Undefined in JS - Isotropic
Cannot read property 'replace' of Undefined in JS ... method such as TypeError: Cannot read properties of undefined (reading 'replace') .
Read more >cannot read property 'replace' of undefined In Grid - Stack ...
I think jQuery cannot find the element. First of all find the element var rowTemplate= document.getElementsByName("rowTemplate");.
Read more >TypeError: Cannot read property 'replace' of undefined
So I tried to learn how to do this on my own by taking two video courses about node and cheerio on udemy...
Read more >Error: Cannot read property 'replace' of undefined #649 - GitHub
Actual behaviour error Error: Evaluation failed: TypeError: Cannot read property 'replace' of undefined at Object.processFormControls...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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: