yads / nodemailer-express-handlebars

A plugin for nodemailer that uses express-handlebars view engine to generate emails
87 stars 30 forks source link

Missing dependency "express-handlebars" #71

Closed LevantinLynx closed 2 months ago

LevantinLynx commented 4 months ago

On install one gets warning " > nodemailer-express-handlebars@6.1.2" has unmet peer dependency "express-handlebars@>= 6.0.0".

This results in an error on run time.

$ node index.js

Error: Cannot find module 'express-handlebars'
Require stack:
- /home/node/app/node_modules/nodemailer-express-handlebars/lib/generator.js
- /home/node/app/node_modules/nodemailer-express-handlebars/lib/index.js
- /home/node/app/node_modules/nodemailer-express-handlebars/index.js
- /home/node/app/src/mailer.js
- /home/node/app/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1219:15)
    at Module._load (node:internal/modules/cjs/loader:1045:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
    at Module.require (node:internal/modules/cjs/loader:1304:12)
    at require (node:internal/modules/helpers:123:16)
    at Object.<anonymous> (/home/node/app/node_modules/nodemailer-express-handlebars/lib/generator.js:4:20)
    at Module._compile (node:internal/modules/cjs/loader:1467:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1551:10)
    at Module.load (node:internal/modules/cjs/loader:1282:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/node/app/node_modules/nodemailer-express-handlebars/lib/generator.js',
    '/home/node/app/node_modules/nodemailer-express-handlebars/lib/index.js',
    '/home/node/app/node_modules/nodemailer-express-handlebars/index.js',
    '/home/node/app/src/mailer.js',
    '/home/node/app/index.js'
  ]
}

The express-handlebars module is loaded by the nodemailer-express-handlebars package under nodemailer-express-handlebars/lib/generator.js:4:20

I checked the npm page and was confused about 0 Dependencies being listed. express-handlebars is listed only as a development dependency. There seems to be an error in the package dependency listing. The "express-handlebars" package should be listed as a dependency, not as a development dependency since it is required to load the package at all.

How to reproduce

This error can be reproduced, if one installs via "yarn install --production" or "npm install --omit=dev". These options are used to reduce size in production installs like docker containers.

yads commented 2 months ago

Yes it's a peer dependency, which means your project needs to include it as well along with nodemailer.