zenorocha / clipboard.js

:scissors: Modern copy to clipboard. No Flash. Just 3kb gzipped :clipboard:
https://clipboardjs.com
MIT License
33.98k stars 3.98k forks source link

couldn't read ClipboardJS from "node_modules" file. #817

Closed ahmed-amir-azouzi closed 2 years ago

ahmed-amir-azouzi commented 2 years ago

Bug Description

I was using ClipboardJS on a personal project. When I open the project from my development environment, everything works fine.

But as soon as I uploaded my project on Github, and hosted it with Github pages, the clipboard copy functionality stopped, and this error message appeared in firefox developer tool.

Screenshot from 2022-08-27 01-44-44

Bug mitigation

And then I stumbled upon a forum discussion where it seemed that this was a common bug; in production environment, loading ClipboardJS from MDN server instead of locally (from "node_modules" file) resolved the bug.

so, in the "index.html" file, on line 46, I have changed this <script src="./node_modules/clipboard/dist/clipboard.min.js"></script> with this <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.10/dist/clipboard.min.js"></script>

P.S

I think this has to do with the ClipboardJS package. My app was really simple, and ClipboardJS was the only package installed.

Development environment

OS: Ubuntu v22.04.1 LTS Web Browser: Firefox v104 npm v8.15.0 && node v16.17.0 IDE: VScode v1.70.2 project's github repo: https://github.com/ahmed-amir-azouzi/vanillaJS-link-shortener/ project's live demo: https://ahmed-amir-azouzi.github.io/vanillaJS-link-shortener/

obetomuniz commented 2 years ago

Hei @ahmed-amir-azouzi, that's really sad that you're figuring issues trying to run ClipboardJS in your project.

Looks like an issue with GitHub Pages, which ignores node_modules folder. You can try what is suggested here. Closing your issue for now, since it's not related to ClipboardJS directly. Feel free to reopen if needed.

ahmed-amir-azouzi commented 2 years ago

Okay, understood. Thank you for your response.

On Tue, Sep 13, 2022 at 6:33 PM Beto Muniz @.***> wrote:

Hei @ahmed-amir-azouzi https://github.com/ahmed-amir-azouzi, that's really sad that you're figuring issues trying to run ClipboardJS in your project.

Looks like an issue with GitHub Pages, which ignores node_modules folder. You can try what is suggested here https://stackoverflow.com/questions/43481269/github-pages-404-on-node-modules-folder. Closing your issue for now, since it's not related to ClipboardJS directly. Feel free to reopen if needed.

— Reply to this email directly, view it on GitHub https://github.com/zenorocha/clipboard.js/issues/817#issuecomment-1245726203, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG2OODS632D4K5U33ANULDDV6C3FVANCNFSM57YOKIHA . You are receiving this because you were mentioned.Message ID: @.***>