xavi- / node-copy-paste

A command line utility that allows read/write (i.e copy/paste) access to the system clipboard.
425 stars 76 forks source link

Creates Error when trying to build with esbuild #71

Closed maribox closed 1 year ago

maribox commented 1 year ago

I don't know if this is a problem of node-copy-paste or esbuild Node Version: 16.18.0, but also 18.15.0

Code:

import { copy, paste } from "copy-paste";

async function main() {
  const question = paste();
  console.log(question);
  let answer = "answertext";
  console.log(answer);
  copy(answer);
}

main().catch((error) => console.error(error));

running with npm run start:

"start": "esbuild src/app.ts --bundle --platform=node --outdir=dist && node dist/app.js",

and what i get in the terminal when running this is:

esbuild src/app.ts --bundle --platform=node --outdir=dist && node dist/app.js

  dist\app.js  542.0kb

Done in 17ms
Error: Command failed: cscript /Nologo C:\Users\marlb\Coden\Node\chatclipboard\dist\fallbacks\paste.vbs
    at checkExecSyncError (node:child_process:861:11)
    at execSync (node:child_process:932:15)
    at exports.paste (C:\Users\marlb\Coden\Node\chatclipboard\dist\app.js:3642:30)
    at main (C:\Users\marlb\Coden\Node\chatclipboard\dist\app.js:3687:48)
    at Object.<anonymous> (C:\Users\marlb\Coden\Node\chatclipboard\dist\app.js:3693:1)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer 49 6e 70 75 74 20 45 72 72 6f 72 3a 20 43 61 6e 20 6e 6f 74 20 66 69 6e 64 20 73 63 72 69 70 74 20 66 69 6c 65 20 22 43 3a 5c 55 73 65 72 73 5c 6d 61 ... 57 more bytes>,
    <Buffer >
  ],
  pid: 15624,
  stdout: <Buffer 49 6e 70 75 74 20 45 72 72 6f 72 3a 20 43 61 6e 20 6e 6f 74 20 66 69 6e 64 20 73 63 72 69 70 74 20 66 69 6c 65 20 22 43 3a 5c 55 73 65 72 73 5c 6d 61 ... 57 more bytes>,
  stderr: <Buffer >
}

It fails at "return config.decode(execSync(pasteCommand));":

    var pasteCommand = [config.paste.command].concat(config.paste.args).join(" ");
    exports.paste = function(callback) {
      if (execSync && !callback) {
        return config.decode(execSync(pasteCommand));
      } else if (callback) {
        var child = spawn(config.paste.command, config.paste.args);
        var done = callback && function() {
          callback.apply(this, arguments);
          done = noop;
        };

If I can be of further help let me know

xavi- commented 1 year ago

Does this error occur on a windows machine?

It seems like error is occurring when running the command:

cscript /Nologo C:\Users\marlb\Coden\Node\chatclipboard\dist\fallbacks\paste.vbs

Any chance you could try running that command manually?

maribox commented 1 year ago

Closing as I'm not using the module anymore