sindresorhus / clipboardy Goto Github PK
View Code? Open in Web Editor NEWAccess the system clipboard (copy/paste)
License: MIT License
Access the system clipboard (copy/paste)
License: MIT License
On Windows some unicode characters are broken while copy-pasted:
It could be bug in win-clipboard – but there is test with same characters, which passes.
Wayland is a new display manager that's about to ship as a default option in the upcoming Red Hat 8, and will be seeing increasing adoption on additional distros as well.
Best resource I've found with resources for talking to the Wayland clipboard is this stackoverflow.
(Alas at the current time Wayland is a pretentious gasbag that declares only input events are supposed to be able to write to the clipboard, but it appears to be up to the compositor/desktop-env to enforce this. Grah.)
Clipboardy works well on Linux and on Windows while developing. However, when I tried to build my app (it's electron app), it raises an error:
Can you add support for watching the clipboard (without polling)?
Like https://github.com/hxfdarling/clipboard-watch does, but without requiring node-ffi
.
This happens only when I run my application as linux service. Executing my node app normally by "node main.js" works good.
Error Thrown at :
/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/lib/linux.js:43
throw makeError(xselError, fallbackError);
^
Full Error Stack :
Error: Both xsel and fallback failed
at makeError (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/lib/linux.js:16:11)
at xselWithFallbackSync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/lib/linux.js:43:10)
at Object.copySync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/lib/linux.js:53:3)
at Object.exports.writeSync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/index.js:45:14)
at Watcher.onChangeDetection (/home/mani/Desktop/mani/tools/screenshot-easy/main.js:85:16)
at Watcher.emit (events.js:310:20)
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:305:19
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:39:7
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:303:7
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:109:10 {
xselError: Error: Command failed: xsel --clipboard --input
xsel: Can't open display: (null)
: Inappropriate ioctl for device
at makeError (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/execa/index.js:174:9)
at Function.module.exports.sync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/execa/index.js:338:15)
at xselWithFallbackSync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/lib/linux.js:38:16)
at Object.copySync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/lib/linux.js:53:3)
at Object.exports.writeSync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/index.js:45:14)
at Watcher.onChangeDetection (/home/mani/Desktop/mani/tools/screenshot-easy/main.js:85:16)
at Watcher.emit (events.js:310:20)
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:305:19
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:39:7
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:303:7 {
code: 1,
stdout: '',
stderr: "xsel: Can't open display: (null)\n: Inappropriate ioctl for device\n",
failed: true,
signal: null,
cmd: 'xsel --clipboard --input',
timedOut: false
},
fallbackError: Error: Command failed: /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/fallbacks/linux/xsel --clipboard --input
/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/fallbacks/linux/xsel: Can't open display: (null)
: Inappropriate ioctl for device
at makeError (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/execa/index.js:174:9)
at Function.module.exports.sync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/execa/index.js:338:15)
at xselWithFallbackSync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/lib/linux.js:41:17)
at Object.copySync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/lib/linux.js:53:3)
at Object.exports.writeSync (/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/index.js:45:14)
at Watcher.onChangeDetection (/home/mani/Desktop/mani/tools/screenshot-easy/main.js:85:16)
at Watcher.emit (events.js:310:20)
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:305:19
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:39:7
at /home/mani/Desktop/mani/tools/screenshot-easy/node_modules/node-watch/lib/watch.js:303:7 {
code: 1,
stdout: '',
stderr: "/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/fallbacks/linux/xsel: Can't open display: (null)\n" +
': Inappropriate ioctl for device\n',
failed: true,
signal: null,
cmd: '/home/mani/Desktop/mani/tools/screenshot-easy/node_modules/clipboardy/fallbacks/linux/xsel --clipboard --input',
timedOut: false
}
}
Is there any way to retrieve the image from system clipboard?
It seems the pbpaste
not support read the image from clipboard.
This is related to #2, I think his fix will most likely work, I also followed this issue on the other popular copy paste library.
Run the following test:
test.only('works with unicode', async t => {
const f = '你好';
t.is(await writeRead(f), f);
});
Now open any other program, notepad etc, and do Edit-Copy or Ctrl+V and you will get 你好.
This is going to be difficult to write a test for since from the libraries standpoint, everything is good. Outside of the library however, it is not actually working with the correct clipboard contents due to encoding.
Hello!
I created VSCode extension with the use of Clipboardy; On windows everything is fine, but when i try to run the command on Ubuntu 18 i got the following error:
Error: Unexpected SIGPIPE
at process.<anonymous> (/snap/code/35/usr/share/code/resources/app/out/bootstrap.js:5:80)
at process.emit (events.js:203:13)
This is my extension: link
How can i solve the problem?
Thanks!
clipboardy threw: Document is not focused
what does this mean -- I am executing in a dialog...
what should I do?
I'm on windows 10 and node 8.10.0
Here's the error I am getting when I create a binary snapshot using pkg(https://www.npmjs.com/package/pkg):
{ Error: write EPIPE
at _errnoException (util.js:1024:11)
at Socket._writeGeneric (net.js:767:25)
at Socket._write (net.js:786:8)
at doWrite (_stream_writable.js:387:12)
at writeOrBuffer (_stream_writable.js:373:5)
at Socket.Writable.write (_stream_writable.js:290:11)
at Socket.write (net.js:704:40)
at Socket.Writable.end (_stream_writable.js:553:10)
at Socket.end (net.js:496:31)
at handleInput (C:\snapshot\package_name\node_modules\execa\index.js:75:17)
code: 'EPIPE',
errno: 'EPIPE',
syscall: 'write',
killed: false,
stdout: '',
stderr: '',
failed: true,
signal: null,
cmd: 'C:\snapshot\package_name\node_modules\clipboardy\fallbacks\windows\clipboard_x86_64.exe --copy',
timedOut: false }
I am not sure what is causing this issue, It works otherwise if I run the code as is without creating a snapshot.
Can anyone please help me?
Thank you!
IssueHunt has been backed by the following sponsors. Become a sponsor
When I using this module in raspberry pi3, has exception:
Error: Both xsel and fallback failed
at makeError (/home/pi/test-rfid/node_modules/clipboardy/lib/linux.js:16:11)
at xselWithFallbackSync (/home/pi/test-rfid/node_modules/clipboardy/lib/linux.js:43:10)
at Object.copySync (/home/pi/test-rfid/node_modules/clipboardy/lib/linux.js:53:3)
at Object.exports.writeSync.text [as writeSync] (/home/pi/test-rfid/node_modules/clipboardy/index.js:39:14)
at Timeout._onTimeout (/home/pi/test-rfid/index.js:44:13)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
node-copy-paste uses the same method of execing clip
on Windows but I had some trouble with Unicode characters on systems running ASCII-only code pages (for instance, those configured with en-US locales).
I've addressed this in my fork of node-copy-paste by setting the code page to 65001
before running clip.exe
.
execa
might already be handling this but I'm not sure.
This is the error i get :
Couldn't find the xsel binary and fallback didn't work. On Debian/Ubuntu you can install xsel with: sudo apt install xsel
I made a discord bot and am trying to launch it in Heroku but the clipboardy does not seems to function . I used Windows 10,Node 14.18.3 and Clipboardy 2.3.0
Attempting to test the following script on Windows 10:
const clipboardy = require('clipboardy');
console.log('clipboard test: ',clipboardy.readSync());
Causes an error to be thrown on node_modules\execa\index.js:275
throw (result.error || new Error(result.stderr === '' ? result.stdout : result.stderr));
Error: Input Error: Can not find script file "C:\test\clipboard\fallbacks\win-read.vbs".
It looks like part of the path is missing, as the file is really under "C:\test\clipboard\node_modules\clipboardy\fallbacks\win-read.vbs"
Hello, I am using this module in a VSCode plugin, and noticed that on windows, when copying and pasting EOL characters the behavior is that they are sometimes stripped. The text should be pasted verbatim, right?
I added a test that fails to explain what I mean: https://github.com/SebastianZaha/clipboardy/commit/481c9b409bbf6445e05e2e0b91f125f003d148f4
I've gotten a couple bug reports on my VS Code extension that uses Clipboardy. It seems that there's sometimes a problem calling clipboardy.write(). I haven't been able to reproduce it myself, but both users are running Linux. One in particular is running: Linux x64 4.9.0-8-amd64 (SolydX 9 / Debian Stretch)
One of them gave the following error log...
[Extension Host] Error pasting... TypeError: Cannot read property 'end' of undefined
at handleInput (/home/sembiance/.vscode/extensions/gazugafan.vscode-indent-on-paste-2.3.2/node_modules/execa/index.js:75:17)
at module.exports (/home/sembiance/.vscode/extensions/gazugafan.vscode-indent-on-paste-2.3.2/node_modules/execa/index.js:273:2)
at Object.copy (/home/sembiance/.vscode/extensions/gazugafan.vscode-indent-on-paste-2.3.2/node_modules/clipboardy/lib/linux.js:17:10)
at Object.exports.write.input [as write] (/home/sembiance/.vscode/extensions/gazugafan.vscode-indent-on-paste-2.3.2/node_modules/clipboardy/index.js:28:20)
at indentOnPaste (/home/sembiance/.vscode/extensions/gazugafan.vscode-indent-on-paste-2.3.2/out/src/extension.js:96:24)
... the line in my extension triggering this error (out/src/extension.js:96:24
) is calling clipboardy.write(). It looks like this...
clipboardy.write(clipboard_1).then(function () {
...
}, function () { pasting = false; });
... which seems to be really straightforward to me. Not sure what's going wrong, but according to the error log it could be up in clipboardy or execa. Any ideas? Are there any known issues with clipboardy on certain flavors of Linux?
I'm using the Clipboard Ring extension (https://github.com/SrTobi/code-clip-ring) in VS Code, which has a dependency on clipboardy ^1.2.3.
I occasionally get the following error, preventing me from pasting the content of my clipboard:
Command failed: C:\Users\Tim\.vscode\extensions\code-clip-ring\node_modules\clipboardy\fallbacks\windows\clipboard_x86_64.exe --paste thread 'main' panicked at 'Error: Could not paste from clipboard: Error { repr: Os { code: 0, message: "The operation completed successfully." } }', src\libcore\result.rs:906:4 note: Run with
RUST_BACKTRACE=1 for a backtrace.
Seems strange that clipboard_x86_64.exe reports an Error with what looks like a success message?
I think restarting VS Code might fix this, but it's a nuisance. Any ideas?
Other info:
I'm running Windows 10 Home N. VS Code: Version 1.24.1.
There is a $60.00 open bounty on this issue. Add more on Issuehunt.
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on Issuehunt to raise funds.
Apparently this library relies on navigator.clipboard
which doesn't exist in Safari 12.
Could you guys add events like clipboardy.on('paste')?
So it triggers a callback with the data pasted
I'm use this moudle in win10, it work nice,
but when use paste, i get 【\r\r\n】, actually i want 【\r\n】;
it show right in terminal, but in file it will bing too many blank lines.
I have checked #17
I didnot use copy.exe, I copy words manual
I've encountered such an issue upon running the tests in Jenkins on a remote Linux machine.
After sudo apt install xsel the following error message is displayed
"Both xsel and fallback failed".
Can you help me to solve this issue, please?
When giving "npm install --save clipboardy" getting below error,
.
.
.
406 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
407 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
408 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
408 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
408 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32
408 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
409 verbose stack Error: ENOENT: no such file or directory, rename 'C:\QFL-Latest\node_modules\clipboardy\node_modules\cross-spawn' -> 'C:\QFL-Latest\node_modules\execa\node_modules\cross-spawn'
409 verbose stack at C:\Program Files\nodejs\node_modules\npm\lib\install\action\move.js:86:7
409 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\iferr\index.js:11:16
409 verbose stack at C:\Program Files\nodejs\node_modules\npm\lib\utils\rename.js:11:14
409 verbose stack at CB (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:93:17)
409 verbose stack at FSReqWrap.oncomplete (fs.js:123:15)
409 verbose stack
409 verbose stack Error: ENOENT: no such file or directory, rename 'C:\QFL-Latest\node_modules\clipboardy\node_modules\cross-spawn' -> 'C:\QFL-Latest\node_modules\execa\node_modules\cross-spawn'
409 verbose stack at Error (native)
Right now when you read the clipboard, clipboardy errors if the clipboard doesn't have text.
Being able to copy other stuff from the clipboard (like: returning a buffer when the clipboard isn't text) would be an amazing feature to have.
I run npx semantic-release-cli setup
, and I provided these configs
? What is your npm registry? https://registry.npmjs.org/
? What is your npm username? eng.dibo
? What is your npm password? [hidden]
? What is your NPM two-factor authentication code? 060355
but the following error occurred
OS: Debian GNU/Linux 10 (buster)
ERR! semantic-release Error: Couldn't find the `xsel` binary and fallback didn't work. On Debian/Ubuntu you can install xsel with: sudo apt install xsel
ERR! semantic-release at makeError (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/lib/linux.js:14:11)
ERR! semantic-release at xselWithFallback (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/lib/linux.js:31:10)
ERR! semantic-release at processTicksAndRejections (internal/process/task_queues.js:94:5)
ERR! semantic-release Error: Couldn't find the `xsel` binary and fallback didn't work. On Debian/Ubuntu you can install xsel with: sudo apt install xsel
ERR! semantic-release at makeError (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/lib/linux.js:14:11)
ERR! semantic-release at xselWithFallback (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/lib/linux.js:31:10)
ERR! semantic-release at processTicksAndRejections (internal/process/task_queues.js:94:5) {
ERR! semantic-release stack: "Error: Couldn't find the `xsel` binary and fallback didn't work. On Debian/Ubuntu you can install xsel with: sudo apt install xsel\n" +
ERR! semantic-release ' at makeError (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/lib/linux.js:14:11)\n' +
ERR! semantic-release ' at xselWithFallback (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/lib/linux.js:31:10)\n' +
ERR! semantic-release ' at processTicksAndRejections (internal/process/task_queues.js:94:5)',
ERR! semantic-release fallbackError: Error: Command failed: /home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/fallbacks/linux/xsel --clipboard --output
ERR! semantic-release /home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/fallbacks/linux/xsel: Can't open display: (null)
ERR! semantic-release : Inappropriate ioctl for device
ERR! semantic-release
ERR! semantic-release
ERR! semantic-release at makeError (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/execa/index.js:174:9)
ERR! semantic-release at /home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/execa/index.js:278:16
ERR! semantic-release at processTicksAndRejections (internal/process/task_queues.js:94:5)
ERR! semantic-release at xselWithFallback (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/lib/linux.js:29:11)
ERR! semantic-release at Object.default (/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/semantic-release-cli/src/lib/github.js:25:32) {
ERR! semantic-release code: 1,
ERR! semantic-release stdout: '',
ERR! semantic-release stderr: "/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/fallbacks/linux/xsel: Can't open display: (null)\n" +
ERR! semantic-release ': Inappropriate ioctl for device\n',
ERR! semantic-release failed: true,
ERR! semantic-release signal: null,
ERR! semantic-release cmd: '/home/sh_eldeeb_2010/.npm/_npx/4b6729947d3d91fc/node_modules/clipboardy/fallbacks/linux/xsel --clipboard --output',
ERR! semantic-release timedOut: false,
ERR! semantic-release killed: false
ERR! semantic-release }
ERR! semantic-release }
When using clipboardy with
Operating system: _Ubuntu 16.04 LTS_
VSCode version: _ 1.20.1_
Markdown+Math version: 2.1.0
by code ...
if (!cb) cb = require('clipboardy');
cb.write(clipTmpl(mdit.render(doc.getText())))
.then(()=>vscode.window.showInformationMessage('Html copied to clipboard!'),
()=>vscode.window.showInformationMessage('Html copying to clipboard failed!'));
... it says 'Html copying to clipboard failed!', whereas with all other operating systems it seems to work well. See ...
goessner/mdmath#44
goessner/mdmath#36
Is it simply so, that Ubuntu is not supported by clipboardy
?
thanks
This module contains .exe files without providing source. That's somewhat weird in an open source module, isn't it?
Cannot use the module in windows 32 bit device.
let clipboardy = require('clipboardy');
//With clipboardy
for (let index = 0; index < 5; index++) {
let value = 'test' + index;
clipboardy.writeSync(value);
console.log(clipboardy.readSync());
}
Running above code throws following error
$ node clipboardy_test.js
<...\node_modules\execa\index.js:277>
throw (result.error || new Error(result.stderr === '' ? result.stdout : result.stderr));
^
Error: spawnSync <...\node_modules\clipboardy\fallbacks\windows\copy.exe> UNKNOWN
at exports._errnoException (util.js:1026:11)
at Object.spawnSync (child_process.js:461:20)
at Function.module.exports.sync (<...\node_modules\execa\index.js:274:30>)
at Object.copySync (<...\node_modules\clipboardy\lib\windows.js:12:26>)
at Object.exports.writeSync.input [as writeSync] (<...\node_modules\clipboardy\index.js:38:13>)
at Object.<anonymous> (<...\clipboardy_test.js:6:16>)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
Then on checking the ' clipboardy \ fallbacks \ windows \ copy.exe' it seems that it supports only 64 bit.
clipboardy \ fallbacks \ windows \ copy.exe is not compatible with running Windows version. Check the system information of the computer and check whether the version of x86 (32 bit) or x64 (64 bit) of the program is required before contacting the software publisher.
This is expected or am i missing something.
My environment:
Node : v6.5.0
Clipboardy: v1.1.4
OS: windows 7 - 32bit
Thanks
Hello,
I am using Nodejs on Termux, a CLI environment for Android.
Currently clipboardy does not work because I don't have xsel. (And I can't build xsel because X11 is not available in Termux.)
However, Termux provides termux-clipboard-get
and termux-clipboard-set
commands which use Android's clipboard API.
Do you think it would possible to add support for these commands in clipboardy?
Module not found: Error: Can't resolve 'child_process' in 'C:\QFL-Latest\node_mo
dules\clipboardy\node_modules\execa'
Hi @sindresorhus,
are we able to get informations wether the user copied some files from filemanager to clipbard and/or set it vice versa? I m looking for such a functionaltity for an electron driven filemanager application.
On GNU+Linux, there are two common programs for clipboard access. xsel
is already implemented, but xclip
could be as well. If ran without any flags, it accepts stdin and writes it to the clipboard buffer. If passed in -o
, it outputs the clipboard buffer to stdout.
https://qa.debian.org/popcon.php?package=xclip
https://qa.debian.org/popcon.php?package=xsel
They have almost the same amount of installs on popcon!
When copying a value, it fails when it's a number type. I suggest using .toString() to add number support. I could make a pull request if this would be accepted.
Error info:
UncaughtSyntaxError: Unexpected token import
at createScript (vm.js:80)
at Object.runInThisContext (vm.js:139)
at Module._compile (module.js:606)
at Object.Module._extensions..js (module.js:653)
at Module.load (module.js:561)
at tryModuleLoad (module.js:504)
at Function.Module._load (module.js:496)
at Module.require (module.js:586)
at require (internal/module.js:11)
at eval (webpack-internal:///clipboardy:1)
package.json
"dependencies": {
"ant-design-vue": "^1.7.5",
"axios": "^0.18.1",
"clipboard": "^2.0.8",
"clipboardy": "^3.0.0",
"electron-store": "^6.0.1",
"moment": "^2.29.1",
"v-viewer": "^1.6.3",
"vditor": "^3.8.7",
"vue": "^2.5.16",
"vue-color": "^2.8.1",
"vue-electron": "^1.0.6",
"vue-monaco-editor": "^0.0.19",
"vue-router": "^3.0.1",
"vuex": "^3.0.1",
"vuex-electron": "^1.0.0"
},
"devDependencies": {
"@mdi/font": "^5.9.55",
"ajv": "^6.5.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-loader": "^7.1.4",
"babel-minify-webpack-plugin": "^0.3.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"cfonts": "^2.1.2",
"chalk": "^2.4.1",
"copy-webpack-plugin": "^4.6.0",
"cross-env": "^5.1.6",
"css-loader": "^0.28.11",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "^2.0.4",
"electron-builder": "^19.19.1",
"electron-debug": "^1.5.0",
"electron-devtools-installer": "^2.2.4",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.0.0",
"eslint-plugin-html": "^4.0.3",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"listr": "^0.14.3",
"material-design-icons-iconfont": "^6.1.0",
"mini-css-extract-plugin": "0.4.0",
"multispinner": "^0.2.1",
"node-loader": "^0.6.0",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1",
"vue-devtools": "^5.1.4",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.2.4",
"vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.15.1",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4",
"webpack-hot-middleware": "^2.22.2",
"webpack-merge": "^4.1.3"
}
vue file:
import clipboard from 'clipboardy'
methods:{
paste () {
const txt = clipboard.readSync()
console.log(txt)
}
Hi I have a app + cypress in a same package, I have installed clipboardy on my dev dependency to support cypress test cases, but with the recent 3.0.0 ESM migration, I am unable to run the Cypress because clipboardy throws the following error on runtime
Error: Webpack Compilation Error
./node_modules/clipboardy/index.js
Module not found: Error: Can't resolve 'node:process' in '/Users/myuser/works/myproject/myproject-app/node_modules/clipboardy'
resolve 'node:process' in '/Users/myuser/works/myproject/myproject-app/node_modules/clipboardy'
Parsed request is a module
using description file: /Users/myuser/works/myproject/myproject-app/node_modules/clipboardy/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
Looked for and couldn't find the file at the following paths:
[/Users/myuser/works/myproject/myproject-app/node_modules/node_modules]
[/Users/myuser/works/myproject/node_modules]
[/Users/myuser/works/node_modules]
[/Users/myuser/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/myuser/works/myproject/myproject-app/node_modules/clipboardy/node_modules/node:process]
[/Users/myuser/works/myproject/myproject-app/node_modules/node:process]
[/Users/myuser/works/myproject/myproject-app/node_modules/clipboardy/node_modules/node:process.js]
[/Users/myuser/works/myproject/myproject-app/node_modules/node:process.js]
[/Users/myuser/works/myproject/myproject-app/node_modules/clipboardy/node_modules/node:process.json]
[/Users/myuser/works/myproject/myproject-app/node_modules/node:process.json]
[/Users/myuser/works/myproject/myproject-app/node_modules/clipboardy/node_modules/node:process.jsx]
[/Users/myuser/works/myproject/myproject-app/node_modules/node:process.jsx]
[/Users/myuser/works/myproject/myproject-app/node_modules/clipboardy/node_modules/node:process.mjs]
[/Users/myuser/works/myproject/myproject-app/node_modules/node:process.mjs]
[/Users/myuser/works/myproject/myproject-app/node_modules/clipboardy/node_modules/node:process.coffee]
[/Users/myuser/works/myproject/myproject-app/node_modules/node:process.coffee]
@ ./node_modules/clipboardy/index.js 1:0-35 9:9-16 15:7-14
@ ./cypress/support/commands.js
@ ./cypress/support/index.js
at Watching.handle [as handler] (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/webpack-preprocessor/dist/index.js:176:23)
at /Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/webpack/lib/Watching.js:99:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/tapable/lib/Hook.js:154:20)
at Watching._done (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/webpack/lib/Watching.js:98:28)
at /Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/webpack/lib/Watching.js:73:19
at Compiler.emitRecords (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/webpack/lib/Compiler.js:499:39)
at /Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/webpack/lib/Watching.js:54:20
at /Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/webpack/lib/Compiler.js:485:14
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/tapable/lib/Hook.js:154:20)
at /Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/webpack/lib/Compiler.js:482:27
at /Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/neo-async/async.js:2818:7
at done (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/neo-async/async.js:3522:9)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/Users/myuser/Library/Caches/Cypress/8.6.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/tapable/lib/Hook.js:154:20)
The Cypress works when I revert back Clipboardy to 2.3.0
Is there any way to fix the above issue with the latest version?
Since yesterday clipboardy started to fail on linux travis tests.
See https://github.com/perezLamed/lamed_io
And https://travis-ci.org/perezLamed/lamed_io/builds/563423693
If I include import clipboard from 'clipboardy'
in a script and then run that script with node --experimental-modules script.js, I get Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. This is with Node 12. package.json includes "type": "module"
In WSL, you can use native windows executables and native linux executables side by side in the same shell. When you install linux node/npm and install clipboardy, it doesn't work as it thinks its on Linux and tries to use xsel, but there is no X server (unless the user installed one).
I had a go at adding support for this in #52 but have closed that as its not a complete solution. WSL support is simple in theory. WSL can run native windows binaries and I can confirm that the fallback executables provided by this module work inside WSL.
The trick is, native windows binaries need to be on a letter drive to run (e.g. C: drive).
This is where things start to get complicated with different paths and environments. WSL has its own filesystem but can also access the standard letter drives under /mnt/c
and so on. When clipboardy is installed in WSL, npm installs those .exe files in the fallback directory but these are in a filesystem that is internal to WSL and not accessible to the rest of Windows. Like I said, they need to be on a letter drive where windows can access them.
To make it work when installed in WSL:
clipboard_ARCH.exe needs to be installed somewhere accessible to windows - maybe %APPDATA%/clipboardy/ or something like that
npm run install-fallback-exes [LOCATION]
)process.env['APPDATA']
, parse it using require('path').win32
API, change 'C:' to '/mnt/c' or whatever drive letter it is, turn the whole thing into a posix path...need to tell clipboardy to use lib/windows.js
when on WSL (since sys.platform === 'linux' it currently tries to use lib/linux.js
)
also need to tell lib/windows.js
to look for those executables in the place we installed them earlier, or put that location on the PATH. It will not work if it just tries to run the executables in their current location wherever the node modules were installed.
IssueHunt has been backed by the following sponsors. Become a sponsor
teststring = "somestring\n"
clipboardy.writeSync(teststring)
teststring != clipboardy.readSync()
execa will strip of trailing new line of stdout, mangling paste operation (on macos pbpaste
)
https://github.com/sindresorhus/execa/blob/master/index.js#L34
X window has three different selection buffers- a primary, a secondary, and a clipboard. It'd be great to be able to use this library to access any.
Atm I'm still using the unpublished https://github.com/rawiroaisen/node-xsel because of this.
On version 3.0.0 clipboardy crashes with following message:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: c:\Users\...\node_modules\clipboardy\index.js
require() of ES modules is not supported.
require() of c:\Users\...\clip-issue\node_modules\clipboardy\index.js from c:\Users\...\clip-issue\src\main.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from c:\Users\...\clip-issue\node_modules\clipboardy\package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1089:13)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (c:\Users\...\clip-issue\src\main.ts:1:1)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Module.m._compile (C:\Users\...\Roaming\npm\node_modules\ts-node\src\index.ts:1295:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Object.require.extensions.<computed> [as .ts] (C:\Users\...\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:1298:12)
Version 2.3.0 works fine. The code in the linked repo uses regular ts import syntax.
Just clone the linked repo, install libs (used yarn) and run the typescript file with ts-node
How about updating execa to 0.6.0? Is there any cons with this?
Thanks for your work!
Unfortunately using the writeSync Method always fails for me on first try with "Error 1418" while retrying it immediately afterwards works....
But before returning the error it waits for 5 Seconds thus resulting in a delay.
Thanks and best regards
Thiemo
pbcopy and pbpaste use locale environment variables to determine the encoding to be used for input and output. For example, absent other locale settings, setting the environment variable LANG=en_US.UTF-8 will cause pbcopy and pbpaste to use UTF-8 for input and output. If an encoding cannot be determined from the locale, the standard C encoding will be used. Use of UTF-8 is recommended. Note that by default the Terminal application uses the UTF-8 encoding and automatically sets the appropriate locale environment variable.
microsoft/vscode#26502 (comment)
Should we set UTF-8
as default encoding, if no specified?
I know that pbpaste
returns the last item copied to clipboard. Is there however a way to return a bigger list of items, say the last 100?
I have added clipboardy 2.0.0 as a dependency of my node project. in one of my TS scripts I added clipboardy.writeSync(val); and when I start the application I get these errors:
ERROR in ./node_modules/clipboardy/node_modules/cross-spawn/index.js Module not found: Error: Can't resolve 'child_process' in 'C:\repositories\ui\ui\node_modules\clipboardy\node_modules\cross-spawn' ERROR in ./node_modules/clipboardy/node_modules/execa/index.js Module not found: Error: Can't resolve 'child_process' in 'C:\repositories\ui\ui\node_modules\clipboardy\node_modules\execa' ERROR in ./node_modules/clipboardy/node_modules/cross-spawn/lib/util/readShebang.js Module not found: Error: Can't resolve 'fs' in 'C:\repositories\ui\ui\node_modules\clipboardy\node_modules\cross-spawn\lib\util' ERROR in ./node_modules/isexe/index.js Module not found: Error: Can't resolve 'fs' in 'C:\repositories\ui\ui\node_modules\isexe' ERROR in ./node_modules/isexe/windows.js Module not found: Error: Can't resolve 'fs' in 'C:\repositories\ui\ui\node_modules\isexe' ERROR in ./node_modules/isexe/mode.js Module not found: Error: Can't resolve 'fs' in 'C:\repositories\ui\ui\node_modules\isexe' ERROR in ./node_modules/clipboardy/node_modules/get-stream/buffer-stream.js Module not found: Error: Can't resolve 'stream' in 'C:\repositories\ui\ui\node_modules\clipboardy\node_modules\get-stream'
Is there any way to fix this?
Having a problem on windows working with more than 32660 characters and this library.
I believe this is the issue:
https://stackoverflow.com/questions/3205027/maximum-length-of-command-line-string/28452546#28452546
Perhaps clipboardy needs to break it up into chunks before processing the data
Related where this was seen including a file of text with this many characters:
VSCodeVim/Vim#1726
We can use document.execCommand
or the Async Clipboard API to create a 1:1 implementation for browsers.
See: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.