Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.2.0 Error: Cannot find module 'debug' #292

Closed
zrrrzzt opened this issue Sep 15, 2016 · 17 comments
Closed

4.2.0 Error: Cannot find module 'debug' #292

zrrrzzt opened this issue Sep 15, 2016 · 17 comments

Comments

@zrrrzzt
Copy link

zrrrzzt commented Sep 15, 2016

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
@Yontih
Copy link

Yontih commented Sep 15, 2016

+1

1 similar comment
@Igor-lkm
Copy link

+1

@peterchoo
Copy link

I've just had to pin to 4.1.0 to prevent this breaking my project build.

@wjdavis5
Copy link

+1

@thinkingserious
Copy link
Contributor

Thanks for the heads up everyone, I'll take a look at this today.

cc @mrfelton

@thinkingserious
Copy link
Contributor

@zrrrzzt,

I can not reproduce this. Is the fix to move the debug dependency to "dependencies"?

@peterchoo
Copy link

@thinkingserious I could reproduce this:

pchoo@pc-pchoo-03:~/dev$ mkdir sg
pchoo@pc-pchoo-03:~/dev$ cd sg
pchoo@pc-pchoo-03:~/dev/sg$ npm i sendgrid
/home/pchoo/dev/sg
└─┬ sendgrid@4.2.0 
  ├─┬ async.ensureasync@0.5.2 
  │ └─┬ async.util.ensureasync@0.5.2 
  │   ├── async.util.restparam@0.5.2 
  │   └── async.util.setimmediate@0.5.2 
  ├─┬ async.queue@0.5.2 
  │ └─┬ async.util.queue@0.5.2 
  │   ├── async.util.arrayeach@0.5.2 
  │   ├── async.util.isarray@0.5.2 
  │   ├── async.util.map@0.5.2 
  │   ├── async.util.noop@0.5.2 
  │   └── async.util.onlyonce@0.5.2 
  ├── bottleneck@1.12.0 
  ├── lodash.chunk@4.2.0 
  └── sendgrid-rest@2.2.1 

npm WARN enoent ENOENT: no such file or directory, open '/home/pchoo/dev/sg/package.json'
npm WARN sg No description
npm WARN sg No repository field.
npm WARN sg No README data
npm WARN sg No license field.
pchoo@pc-pchoo-03:~/dev/sg$ node
> const sg = require('sendgrid');
Error: Cannot find module 'debug'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/pchoo/dev/sg/node_modules/sendgrid/lib/helpers/contact-importer/contact-importer.js:7:13)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
> 
(To exit, press ^C again or type .exit)
> 
pchoo@pc-pchoo-03:~/dev/sg$ node --version
v6.2.2
pchoo@pc-pchoo-03:~/dev/sg$ 

However this "fixed" it:

pchoo@pc-pchoo-03:~/dev/sg$ npm i debug
/home/pchoo/dev/sg
└─┬ debug@2.2.0 
  └── ms@0.7.1 

npm WARN enoent ENOENT: no such file or directory, open '/home/pchoo/dev/sg/package.json'
npm WARN sg No description
npm WARN sg No repository field.
npm WARN sg No README data
npm WARN sg No license field.
pchoo@pc-pchoo-03:~/dev/sg$ node
> const sg = require('sendgrid');
undefined
> 

Do you possibly have debug installed globally on your machine?

@peterchoo
Copy link

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.

@thinkingserious
Copy link
Contributor

@peterchoo,

I just checked and it was not installed globally.

Everyone,

It looks like I just need to either move that dependency to "dependencies" or only activate those debug messages when in development mode.

Does anyone have a preference?

@peterchoo
Copy link

@thinkingserious

Just to double check there were no other issues, I did the following

pchoo@pc-pchoo-03:~/dev$ mkdir sg2 && cd sg2
pchoo@pc-pchoo-03:~/dev/sg2$ npm i sendgrid
/home/pchoo/dev/sg2
└─┬ sendgrid@4.2.0 
  ├─┬ async.ensureasync@0.5.2 
  │ └─┬ async.util.ensureasync@0.5.2 
  │   ├── async.util.restparam@0.5.2 
  │   └── async.util.setimmediate@0.5.2 
  ├─┬ async.queue@0.5.2 
  │ └─┬ async.util.queue@0.5.2 
  │   ├── async.util.arrayeach@0.5.2 
  │   ├── async.util.isarray@0.5.2 
  │   ├── async.util.map@0.5.2 
  │   ├── async.util.noop@0.5.2 
  │   └── async.util.onlyonce@0.5.2 
  ├── bottleneck@1.12.0 
  ├── lodash.chunk@4.2.0 
  └── sendgrid-rest@2.2.1 

npm WARN enoent ENOENT: no such file or directory, open '/home/pchoo/dev/sg2/package.json'
npm WARN sg2 No description
npm WARN sg2 No repository field.
npm WARN sg2 No README data
npm WARN sg2 No license field.
pchoo@pc-pchoo-03:~/dev/sg2$ cd node_modules/sendgrid/
pchoo@pc-pchoo-03:~/dev/sg2/node_modules/sendgrid$ vi package.json 

// Move debug from devDependencies to dependencies

pchoo@pc-pchoo-03:~/dev/sg2/node_modules/sendgrid$ npm i --production
sendgrid@4.2.0 /home/pchoo/dev/sg2/node_modules/sendgrid
├─┬ async.ensureasync@0.5.2 
│ └─┬ async.util.ensureasync@0.5.2 
│   ├── async.util.restparam@0.5.2 
│   └── async.util.setimmediate@0.5.2 
├─┬ async.queue@0.5.2 
│ └─┬ async.util.queue@0.5.2 
│   ├── async.util.arrayeach@0.5.2 
│   ├── async.util.isarray@0.5.2 
│   ├── async.util.map@0.5.2 
│   ├── async.util.noop@0.5.2 
│   └── async.util.onlyonce@0.5.2 
├── bottleneck@1.12.0 
├─┬ debug@2.2.0 
│ └── ms@0.7.1 
├── lodash.chunk@4.2.0 
└── sendgrid-rest@2.2.1 

pchoo@pc-pchoo-03:~/dev/sg2/node_modules/sendgrid$ cd ../..
pchoo@pc-pchoo-03:~/dev/sg2$ node
> const sg = require('sendgrid');
undefined
> 

@peterchoo
Copy link

@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.

@zrrrzzt
Copy link
Author

zrrrzzt commented Sep 15, 2016

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

@thinkingserious
Copy link
Contributor

@zrrrzzt,

Would you want those messages in a production environment? This is where I'm conflicted. Perhaps it should be optional?

It seems like those messages would be good to log in production, but the name of the package suggests it would be used only for debugging.

@peterchoo
Copy link

peterchoo commented Sep 15, 2016

@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.

@zrrrzzt
Copy link
Author

zrrrzzt commented Sep 15, 2016

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

@thinkingserious
Copy link
Contributor

Great! I'll make the fix today. It will be v4.2.1

@thinkingserious
Copy link
Contributor

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

Thanks again for all the great feedback 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants