clipboard.js: Cannot find module './clipboard-action'
Minimal example
Using Clipboard v2.0.1 and importing it
import Clipboard from 'clipboard'
Expected behaviour
Can import Clipboard. I fixed it downgrading to Clipboard v1.7.1
Actual behaviour
Got error
Cannot find module './clipboard-action'
Browsers affected
I tested it on Chrome.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 7
- Comments: 18 (2 by maintainers)
https://github.com/zenorocha/clipboard.js/blob/3382ea3d14a6c46d274df6147c73a83ef47e41b3/dist/clipboard.js#L506
This line is the issue. It’s referencing a relative path that doesn’t exist. Very weird, looks like it might be webpack’s fault. And no idea why this issue still exists, it’s a really annoying one.
@fibo how do you avoid the issue mentioned in #468?
This is seriously starting to drive me nuts. @zenorocha appreciate your opinion here, otherwise I’m going to fork.
I just released a new version
2.0.2
that uses Webpack 4 for the module bundling. Can you please test and let me know if the problem was fixed? Thanks!I’m working with an Ember-Addon, using the
ember-auto-import
to bring in Clipboard-2.0.1 fromyarn add --dev clipboard
. I’m simply importing clipboard in my component as follows:import Clipboard from 'clipboard';
. All works great when I run my DUMMY test app locally (dev/text) 👍If I run a production build of the DUMMY app (which I deploy for demo purposes), I get errors. 👎
I got around this because I don’t care about Clipboard-2.0.1 for my feeble demo site and I reverted to Clipboard-1.7.1:
yarn add --dev clipboard@^1.7.1
. My production build is now green and happy.