mjmlio / gulp-mjml

Add Gulp to your MJML workflow!
MIT License
162 stars 37 forks source link

Error when compiling templates. #11

Closed rikschennink closed 7 years ago

rikschennink commented 7 years ago

Suddenly after reinstalling npm modules we get this error:

TypeError: must start with number, buffer, array or string`

We traced it to this line:

output.contents = new Buffer(mjmlEngine.mjml2html(file.contents.toString()));

Changing it to this makes it work:

output.contents = new Buffer(JSON.stringify(mjmlEngine.mjml2html(file.contents.toString())));
iRyusa commented 7 years ago

Hello there,

Can you check you're using MJML3 ? In MJML3, mjml2html returns an Object with errors and html properties.

rikschennink commented 7 years ago

The gulp-mjml package has mjml version set to "latest" so I guess it pulled 3.0.0 when I ran a fresh nmp install this afternoon.

chibani commented 7 years ago

Same error here. I tried to plug mjml with gulp. I globally installed mjml 2.3.3 (because the 3.x doc is not available), unfortunately, gulp-mjml installs a 3.x version (aka "latest") :/

CyrilCalmels commented 7 years ago

Same issue, I get exactly the same symptoms and I can't fix it because gulp-mjml uses the latest version of mjml anyway.

Change the line to this also makes it work :

output.contents = new Buffer(mjmlEngine.mjml2html(file.contents.toString()).html);

But I'd like to know if somebody found a "real" workaround or if we must wait the next update of gulp-mjml ?

iRyusa commented 7 years ago

The fix should be available tomorrow ! Sorry about that

SMontenez commented 7 years ago

Hi, same problem here !

Thanks for the fix, is it possible to also remove the "latest" dependency on mjml ? It's quite dangerous for our production app, as updates are made without any warning. As you take care of both libraries, I think you could handle versions of mjml manually here so users of gulp-mjml are aware of version bumps.

iRyusa commented 7 years ago

👍 Agree

seanhak commented 7 years ago

Hi, Is the fix out? I'm still "stuck" at v 1.1 with above issues. Any temporary fixes advised?

iRyusa commented 7 years ago

The fix is here : #12 it should be available today