Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 846
Daniel Avatar asked Feb 10 '26 00:02

Daniel


1 Answers

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.

like image 99
Iceman Avatar answered Feb 12 '26 14:02

Iceman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!