Archived post: posted sometime between 2016 and 2022.

Copy to clipboard from NodeJS

const output = "some string";
require("child_process").spawn("clip").stdin.end(output);