在电子中需要“ iohook”模块时出错

时间:2019-03-17 19:16:07

标签: node.js electron

我最近刚开始电子学。 我在nodejs v10中使用了这个模块(iohook),它工作正常。 但是当我要求使用Electronic js时,会出现以下错误:

 Error: Cannot find module '.\node_modules\iohook\builds\electron-v69-win32-x64\build\Release\iohook.node'
at Module._resolveFilename (internal/modules/cjs/loader.js:584:15)
at Function.Module._resolveFilename (.\electron\dist\resources\electron.asar\common\reset-search-paths.js:43:12)
at Function.Module._load (internal/modules/cjs/loader.js:510:25)
at Module.require (internal/modules/cjs/loader.js:640:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C.\node_modules\iohook\index.js:10:21)
at Object.<anonymous> (.\node_modules\iohook\index.js:397:3)
at Module._compile (internal/modules/cjs/loader.js:693:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10)
at Module.load (internal/modules/cjs/loader.js:602:32)

。 和我的代码

  let win;
const url = require('url');
const path = require('path');
const iohook = require('iohook');
function createWindow(electron) {

let screenXY= getScreenXY(electron);
win = new electron.BrowserWindow({
  /////code
});
win.loadURL(url.format ({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file:',
    slashes: true,

    }))
}

function getScreenXY(electron) {
    let screenElectron = electron.screen;
    let mainScreen = screenElectron.getPrimaryDisplay();
    let dimensions = mainScreen.size;
    return dimensions;
}
module.exports=createWindow;

并在Windows 10中运行

怎么了?

谢谢

0 个答案:

没有答案