forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.66k stars 339 forks source link

Babel conflict with express-react-views #407

Closed robincsamuel closed 3 years ago

robincsamuel commented 3 years ago

I'm using express-react-views as the view engine for my express app, which uses babel.

The app is breaking when I require email-templates. I didn't even instantiate the class, but just require('email-templtes)`

Error: Cannot find module 'babel-core'
Require stack:
- /Project/node_modules/consolidate/lib/consolidate.js
- /Project/node_modules/consolidate/index.js
- /Project/node_modules/email-templates/lib/index.js
- /Project/src/services/mailer.js
- /Project/src/container.js
- /Project/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at requireReact (/Project/node_modules/consolidate/lib/consolidate.js:1399:51)
    at Object.newLoader [as .jsx] (/Project/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at View.renderFile [as engine] (/Project/node_modules/express-react-views/index.js:66:23)
    at View.render (/Project/node_modules/express/lib/view.js:135:8)
    at tryRender (/Project/node_modules/express/lib/application.js:640:10)
    at Function.render (/Project/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/Project/node_modules/express/lib/response.js:1012:7)
    at errorHandler (/Project/src/utils/errorHandler.js:42:8)
niftylettuce commented 3 years ago

Seems like an issue with a package or configuration of Babel / your project specifically.

Why not just use Lad?

robincsamuel commented 3 years ago

Yeah, it’s a problem with express-react-views, which does babel/register.

Thanks!