question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

impact on production, how to use debug (use as devDependency?)

See original GitHub issue

I first used debug as devDependency, but obviously that would not work.

What is the perf impact on a debug call in production, i.e. process.env.DEBUG not set or NODE_ENV = production?

Is it recommended to wrap debug in a separate file and use require('./debug.js'), that way it could be a devDependency.

if (!!process.env.DEBUG || process.env.NODE_ENV != 'production'){
    try {
        module.exports = require('debug');
        return;
    } catch(e){}
}

module.exports = function(){
    return function(){};
};

Would anybody recommend using or not using debug like that?

Thanks for your help

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
thisconnectcommented, Oct 19, 2015
var debug = require('debug')('debug');
console.log(debug.toString());
// logs
// function disabled() {
//  }

OK without DEBUG it is actually an empty function, (if my test is correct). So no impact other than calling an empty function. If this is correct, I guess my only question is, is this correct and do people use debug as regular dependency.

0reactions
thisconnectcommented, Oct 27, 2015

The impact of calling debug without process.env.DEBUG is negligible, as if I understand it correctly, it is like calling an empty function everywhere. Closing…

Read more comments on GitHub >

github_iconTop Results From Across the Web

impact on production, how to use debug (use as ... - GitHub
I first used debug as devDependency, but obviously that would not work. What is the perf impact on a debug call in production, ......
Read more >
Is this a dependency or devDependency? - With Blue Ink
The answer gets less clear-cut when we are dealing with applications that are client-side (running in browsers), pre-processed (e.g. that use ...
Read more >
Why is debug used as dependency and not devDependency?
I have seen that a lot of node modules/frameworks (express, sockets.io, body-parser) that use debug as dependency rather than as devDependency, ...
Read more >
Do npm dependencies and devDependencies effect your ...
To install all modules listed in both dependencies and devDependencies when NODE_ENV environment variable is set to production , you can use -- ......
Read more >
How to tame the devDependencies of your project? - SurviveJS
I've found that the combination of using a package and mrm to manage development dependencies is powerful as it allows you to encapsulate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found