admin管理员组文章数量:1129469
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.
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.
Share Improve this question edited May 1, 2017 at 7:48 Sindre Sorhus 63.4k40 gold badges174 silver badges234 bronze badges asked Oct 15, 2011 at 14:50 TowerTower 103k131 gold badges364 silver badges517 bronze badges11 Answers
Reset to default 181For 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.
import clipboardy from 'clipboardy';
// Copy
clipboardy.writeSync('
本文标签:
javascriptCopy to clipboard in NodejsStack Overflow
版权声明:本文标题:javascript - Copy to clipboard in Node.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1736746195a1950788.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论