mjml icon indicating copy to clipboard operation
mjml copied to clipboard

Cannot read property 'map' of undefined

Open notflip opened this issue 3 years ago • 3 comments

Describe the bug I'm getting the error Cannot read property 'map' of undefined I can reach the error by using the built-in validation mjml --validate ./file.mjml

To Reproduce Steps to reproduce the behavior: This is the MJML that is causing this error

<mjml>
    <mj-head>
        <mj-include path="./styles/custom.style.mjml" /> <------ this file is empty
    </mj-head>
    <mj-body>
        ...
    </mj-body>
</mjml>

Expected behavior I don't see any map() function inside the mjml, so I would suppose the mjml would build.

MJML environment (please complete the following information):

  • OS: MacOS
  • MJML Version: 4.11.0
  • MJML tool used: Node MJML

notflip avatar Jan 28 '22 15:01 notflip

Can reproduce the issue when the include is not a properly formatted MJML document.

Can you show the content of <mj-include path="./styles/localdining.style.mjml" /> please ?

iRyusa avatar Feb 07 '22 08:02 iRyusa

@iRyusa I found the solution, the issue was that the included file (custom.style.mjml) file was empty, which caused the error, I added an empty <mj-style></mj-style> tag, which solved it.

notflip avatar Feb 07 '22 08:02 notflip

cc @kmcb777 maybe we should catch this? It shouldn't be that hard to know if a file is empty

iRyusa avatar Feb 11 '22 17:02 iRyusa