You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
debug.enable() fails since debug() is a native function in Chrome #153
Debug works in the browser as well, currently persisted by localStorage. For example if you have worker:a and worker:b as shown below, and wish to debug both type debug.enable('worker:*') in the console and refresh the page
Obviously running this command fails because debug is a native, and deprecated, function in Chrome (while it doe snot exist in Firefox).
So, how to use debug in the browser? should I include the library in the window namespace to make it available from the console?
Clear. I'm not using the standalone debug.js but instead browserifying my own app, which internally requires('debug').
Just a final question: If my app includes different libraries and those libraries internally require 'debug' module, and then I also load the standalone debug.js in my web, would window.debug be the same object as MyApp.debug and MyApp.someLibrary.debug?
It depends really. Ideally, yes, would be the answer. But in reality, if there's multiple copies of the debug module within your node_modules directory, then there's a possibility that require('debug') calls in different module would return different objects.
You can use npm dedup, and check to make sure all modules are using compatible versions of debug, in order to avoid that situation.
Activity
TooTallNate commentedon Nov 5, 2014
Are you actually trying it?
I've never seemed to have any problems in Chrome.
ibc commentedon Nov 5, 2014
Actually it works if my JS app exposes
debugas an internal accessor:Then
browserify -s MyAppand load the bundle script in my page, so I can run in the browser console:This works, really :)
But if my JS app exposes the 'debug' module in the 'window' namespace then I'm overriding the
debug()method (deprecated) that Chrome provides:I have no idea what that is and what that does.
BTW, the README says:
but for that to work I need to expose the 'debug' module in the 'window' namespace, or do I miss something?
TooTallNate commentedon Nov 5, 2014
Are you literally doing? This seems to work for me:
The README comment is assuming that you're using the standalone
debug.jsfile in the dist dir.It's assumed that if you're browserifying yourself, then you can figure out how to expose the variable in a manner appropriate for your app.
ibc commentedon Nov 5, 2014
Clear. I'm not using the standalone
debug.jsbut instead browserifying my own app, which internallyrequires('debug').Just a final question: If my app includes different libraries and those libraries internally require 'debug' module, and then I also load the standalone
debug.jsin my web, wouldwindow.debugbe the same object asMyApp.debugandMyApp.someLibrary.debug?TooTallNate commentedon Nov 5, 2014
It depends really. Ideally, yes, would be the answer. But in reality, if there's multiple copies of the
debugmodule within yournode_modulesdirectory, then there's a possibility thatrequire('debug')calls in different module would return different objects.You can use
npm dedup, and check to make sure all modules are using compatible versions ofdebug, in order to avoid that situation.ibc commentedon Nov 5, 2014
Clear. Thanks a lot.
(I'll close this issue as it is not an issue at the end)