mousetrap icon indicating copy to clipboard operation
mousetrap copied to clipboard

Required module "mousetrap" is empty

Open ghoomfrog opened this issue 5 years ago • 1 comments

I'm making an Electron application, and I need keyboard shortcuts for it, that's why I installed mousetrap into my project directory with npm (in node_modules), I also installed mousetrap's dependencies.

The problem is that when I let mousetrap = require("mousetrap"), I find that mousetrap is an empty object. Why?

And, can someone tell me how can I properly use mousetrap with Node.js, especially with Electron?

ghoomfrog avatar May 09 '19 16:05 ghoomfrog

Try doing this:

if (!this.mousetrap) {
  this.mousetrap = new Mousetrap(window, true);
}

jonschlinkert avatar Aug 16 '19 01:08 jonschlinkert