Wednesday, 17 May 2017

Alternative to remote.require in electron renderer

If I require('mymodule') directly in the renderer, I get the error:

Error: Cannot find module 'mymodule'
    at Module._resolveFilename (module.js:470)
    at Function.Module._resolveFilename (VM65:35)
    at Function.Module._load (module.js:418)
    at Module.require (module.js:498)
    at require (internal/module.js:20)

As a workaround, I am currently using require('electron').remote.require('mymodule'). Unfortunately I believe this is causing problems for my particular module. Are there known limitations to including modules this way? Are there issues with sharing node a Buffer between the renderer and a native C++ module included via remote?

Am I able to use an explicit path in my require() to avoid the error above when requiring directly? If so, why is remote.require needed at all?



via logidelic

No comments:

Post a Comment