Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console has no method 'debug' in Nodejs?

The console.debug() function can be invoked in the browser console.

However there is one error when console.debug() is called in Nodejs.

TypeError: Object #<Console> has no method 'debug'
    at Object.<anonymous> (c:\share\node\receive.js:20:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3

Why? Is there any way to replace console.debug in Nodejs?

like image 237
zangw Avatar asked Mar 03 '15 10:03

zangw


People also ask

How do I enable debug in Node JS?

Open up Preferences > Settings and in the search box type in “node debug”. Under the Extensions tab there should be one extension titled “Node debug”. From here, click the first box: Debug > Node: Auto Attach and set the drop down to “on”. You're almost ready to go now.

Can we use debugger in Node JS?

To use it, start Node. js with the inspect argument followed by the path to the script to debug. The debugger automatically breaks on the first executable line. To instead run until the first breakpoint (specified by a debugger statement), set the NODE_INSPECT_RESUME_ON_START environment variable to 1 .

How do you add a breakpoint in Node JS?

When debugging in Node. js, we add a breakpoint by adding the debugger keyword directly to our code. We can then go from one breakpoint to the next by pressing c in the debugger console instead of n . At each breakpoint, we can set up watchers for expressions of interest.

Does console error work in Node JS?

error() function from console class of Node. js is used to display an error messages on the console. It prints to stderr with newline.


1 Answers

There's no console.debug() method in NodeJS. Here is the documentation for the console object, so you can choose the best method for you to use.

like image 189
Morry Avatar answered Sep 23 '22 20:09

Morry