Is there a way you can copy to clipboard in Node.js? Any modules or ideas what so ever? I'm using Node.js on a desktop application. Hopefully that clears up why I want it to be able to achieve this.
Like many of the other answer mentioned, to copy and paste in node you need to call out to an external program. In the case of node-copy-paste , it calls out to pbcopy/pbpaste (for OSX), xclip (for linux), and clip (for windows).
A command line utility that allows read/write (i.e copy/paste) access to the system clipboard. It does this by wrapping pbcopy/pbpaste (for OSX), xclip (for Linux and OpenBSD), and clip (for Windows). Currently works with node.
Select the first item that you want to copy, and press CTRL+C. Continue copying items from the same or other files until you have collected all of the items that you want. The Office Clipboard can hold up to 24 items.
Updated: 05/03/2022 by Computer Hope. The clipboard, also known as pasteboard, is a particular location on a computer, phone, or tablet memory that temporarily stores cut or copied text or other data. Once something is stored in the clipboard, it can be pasted to a new location.
For OS X:
function pbcopy(data) {
var proc = require('child_process').spawn('pbcopy');
proc.stdin.write(data); proc.stdin.end();
}
write()
can take a buffer or a string. The default encoding for a string will be utf-8.
Check out clipboardy
. It lets you copy/paste cross-platform. It is more actively maintained than the copy-paste
module mentioned in another answer and it fixes many of that module's issues.
const clipboardy = require('clipboardy');
// Copy
clipboardy.writeSync('🦄');
// Paste
clipboardy.readSync();
//🦄
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With