sendgrid-nodejs: 4.2.0 Error: Cannot find module 'debug'

Issue Summary

debug is listed as a dev-dependency. As a result you’ll get an error if you install this module from npm

Steps to Reproduce

  1. $ npm i sendgrid
  2. $ node
  3. > const sg = require('sendgrid')

returns this result

Error: Cannot find module 'debug'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/geir/Downloads/sendgridbreaking/node_modules/sendgrid/lib/helpers/contact-importer/contact-importer.js:7:13)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

Technical details:

  • sendgrid-nodejs Version: 4.2.0
  • Node.js Version: 4.5.0

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 3
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

If debug is only used for …ehrm debugging in dev I would prefer to not have it as a regular dependency.

thx for all the checking @peterchoo

Fixed: https://github.com/sendgrid/sendgrid-nodejs/releases/tag/v4.2.1

Thanks again for all the great feedback 👍

After reading the arguments from @peterchoo I changed my mind. I support adding debug as a regular dependency as well.

@thinkingserious @zrrrzzt

debug will only log out messages if you have set the DEBUG env variable at run time.

I think that if you want to have debug included with sendgrid, you would need to decide if you need any more specific types of message. Have a read of https://www.npmjs.com/package/debug if you haven’t yet, in a simple example using var debug = require('debug')('sendgrid'); would mean DEBUG=sendgrid node example/app will debug log everything where debug is used.

However if you had a particular section of your code, such as the contacts importer that introduced this issue and had var debug = require('debug')('sendgrid:contacts-importer');, then we could be specific about which debug messages we have.

If you wish to use this functionality, it becomes a dependency. It will not affect people using the sendgrid package unless they have DEBUG set.

//Edit

I’m in favour of you adding the debug package as a dependency, and gradually improving the debug logging. It will not be a massive increase in size, or affect the running of your code. It will not affect me as a user unless I enable it. It would be a useful tool if I have any issues in the future.

@thinkingserious Sorry for all the double posts, we appear to have commented at the same time.

I don’t have a preference between those two, as long as we can use your package without it breaking our production build. We might find it useful to be able to enable logging of this kind, although having quickly grep’d for debug it looks like this is the only file using it and is not in keeping with the rest of the package.

Additionally, yes, that would fix it - the debug is being used in the production code, and not part of something like a build toolchain that isn’t required to be used in production applications.