Daniel Daniel - 1 year ago 42
Javascript Question

Why "print" doesn't work in node.js?

I have

code with function
. It works correctly in console of web browser, but when I run this code using node i obtain error:

ReferenceError: print is not defined

Of course I can use
, but I would like to know why
is not implemented in

Answer Source

The print or window.print() opens the Print Dialog to print the current document.

In Contrast, the console.log() outputs a message to the Web Console.

If your intention was to actually print a file to a 'hardware printer', from Node.js then have a look at projects such as node-printer.