Daniel Daniel - 3 months ago 10
Javascript Question

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

I have

JavsScript
code with function
print
. 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
console.log
, but I would like to know why
print
is not implemented in
node
?

Answer

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.

Comments