mjml: mjml2html is not a function
When trying out MJML4 with the node example provided
import { mjml2html } from 'mjml'
/*
Compile an mjml string
*/
const htmlOutput = mjml2html(`
<mjml>
<mj-body>
<mj-section>
<mj-column>
<mj-text>
Hello World!
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
`)
/*
Print the responsive HTML generated and MJML errors if any
*/
console.log(htmlOutput)
I get the following message:
const htmlOutput = mjml_1.mjml2html(`
TypeError: mjml_1.mjml2html is not a function
Is the naming changed?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (5 by maintainers)
Sorry my fault indeed. It was part of a typescript project so I had to do
I also had this issue, and I found this solution.
import mjml2html = require('mjml');It works very well with typescript!
I resolved the issue by importing it like this:
import mjml2html from 'mjml';, and I added theesModuleInterop: trueproperty to the ts.config.json file.how would this work with gulp-mjml ?
It worked but I didn’t have any type support in Webstorm using this method
@ruudboon can you try just replacing
by
I tried and it works fine