sudodoki / copy-to-clipboard

Copy stuff into clipboard from your browser using JS

Home Page:http://sudodoki.github.io/copy-to-clipboard/example/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error using clipboard-copy on glitch.com

rotimi-best opened this issue · comments

I am hosting my app on glitch.com and running the code below give an error message

Code:

const copy = require('clipboard-copy');

copy('copied');

Error Message:
UnhandledPromiseRejectionWarning: ReferenceError: navigator is not defined at clipboardCopy (/rbd/pnpm-volume/9f6c9fba-aa0c-4aca-a74c-4ee444e59487/node_modules/.registry.npmjs.org/clipboard-copy/2.0.1/node_modules/clipboard-copy/index.js:5:3)

@rotimi-best where are you running this code? In glitch itself in scripts that ran in browser, require wouldn't be defined, and if it's defined, you probably run this on server, which won't work.
Let me know whether you have figured this out, right now don't think it's enough info to figure this out.

I ran it in on the server.

you probably run this on server, which won't work

Yes this is right, why didn't it work since it ran on my local machine?