I’m new to Electron, so I can’t understand what happen about this.
I write a module call
In the main process, the code
const configuration = require('../app/js/configuration') doesn’t have error, because I can get the window. But in the render process, the code
const configuration = require('./configuration') can cause an error:
Uncaught Error: Cannot find module './configuration' at Module._resolveFilename (module.js:470:15) at Function.Module._resolveFilename (F:\Web\wxminpgEditor\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at file:///F:/Web/wxminpgEditor/app/js/settings.js:6:23
I have found a solution, when I change the code to
const path = require('path') const configuration = require(path.resolve('app/js/configuration.js'))
it can run!
So my question is why in render process I can’t use relative path to find my module and how can I use relative path (because I think the solution is too long). I am not really clear about this. Can you help me? Thanks!
Here is my project folder
main.js is main process,
setting.js is render process.