wix-incubator / mjml-react

React component library to generate the HTML emails on the fly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mjml-react import error

jtam2 opened this issue · comments

I am trying to use mjml-react in my react app that I created with create-react-app but when I try to import {Mjml} from 'mjml-react' and run npm run start my browser gives me this error:

Error: Cannot find module '../lib/utils.js' 

The console:

tools sync:2 Uncaught Error: Cannot find module '../lib/utils.js'
    at Function.webpackEmptyContext [as resolve] (tools sync:2)
    at node.js:17
    at Array.map (<anonymous>)
    at Object../node_modules/uglify-js/tools/node.js (node.js:3)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object../node_modules/html-minifier/src/htmlminifier.js (htmlminifier.js:8)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object.<anonymous> (index.js:80)
    at Object../node_modules/mjml-core/lib/index.js (index.js:410)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object../node_modules/mjml/lib/index.js (index.js:10)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Module../node_modules/mjml-react/dist/es/src/index.js (index.js:1)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Module../src/App.js (App.css?4433:45)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Module../src/index.js (index.css?f3f6:45)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object.1 (serviceWorker.js:141)
    at __webpack_require__ (bootstrap:784)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpC
commented

Ran into this issue as well, this occurs because the main MJML module only supports being run on a server, not on the browser: mjmlio/mjml#1365

Thanks @zhicong for detailed comment. yes indeed it's a limitation of mjml itself.