question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

require('mjml') is no longer exporting mjml2html as default method

See original GitHub issue

When importing mjml as a node module the method mjml2html is no longer available as default export. This problem occurs since the 4.2 release.

Steps to reproduce the behavior:

  1. Import mjml in a node project using require('mjml')
  2. Convert a template String by calling mjml(templateString, cfg)
  3. Error message mjml is not a function

Expected behavior The given mjml templateString is converted to html.

MJML environment (please complete the following information):

  • Node 10.11, npm 6.4.1
  • MJML V4.2.0

The new export for handleMjmlConfig seems to be causing this problem: https://github.com/mjmlio/mjml/blob/master/packages/mjml/src/index.js#L49-L51

A workaround to fix this issue on the user’s side is explicitly importing the default property: require('mjml').default

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Jpuntcommented, Nov 27, 2018

I’m not sure how this is fixed. At least in TypeScript, I cannot do either of these:

import mjml2html from "mjml";
import * as mjml2html from "mjml";

The only way to make this work is:

const mjml2html = require("mjml"); // tslint:disable-line no-var-requires

Which is… undesirable. What is the plan for this?

1reaction
iRyusacommented, Oct 16, 2018

We’ve discussed a bit and it was used in mjml-app, so we might need to check that it works fine with the app first

Read more comments on GitHub >

github_iconTop Results From Across the Web

mjml-guides – Documentation for MJML - The Responsive ...
The default behavior of the MJML translation engine is to divide the section space (600px by default, but it can be changed with...
Read more >
Mjml NPM - npm.io
MJML is a markup language created by Mailjet and designed to reduce the pain of coding a responsive email. Its semantic syntax makes...
Read more >
Mjml Editor - StackBlitz
import mjml from './sample.js';. export default function App() {. let [code, setCode] = useState(mjml);. let [mobile, setMobile] = useState(true);.
Read more >
mjml - npm
Installation. You can install MJML with NPM to use it with NodeJS or the Command Line Interface. If you're not sure what ...
Read more >
mjml-master-pathable - npm Package Health Analysis - Snyk
Learn more about mjml-master-pathable: package health score, ... You can pass optional options as an object to the mjml2html function: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found