0

I have my project structure as follow.

Main Project
  -Project A(Electron + React)
   -node_modules
   -package.json
   -src
   -public
    -electron.js

  -Project B(Terminal based)
   -node_modules
   -package.json
   -src
    -lib
     -terminal.js

What I want to achieve is from electron.js, call a function named 'config', which is inside terminal.js file. How can I do that?

I have tried to use child-process but its throwing error. I am new to Electron and any help would be good.

user10518298
  • 169
  • 1
  • 16
  • I think you are going to need the electron remote package: https://www.npmjs.com/package/@electron/remote – Madriesen Oct 12 '21 at 16:54
  • Add package from `Project B` as dependency to your `Project A`, import it in your `electron.js` and call it. If you want to call it from render process use IpcRender to emit some event. Listen to it in electron.js via IpcMain and run the function. – Yury Tarabanko Oct 12 '21 at 17:00
  • @YuryTarabanko could you please elaborate a little on how to add Project B as dependency to Project A. – user10518298 Oct 12 '21 at 17:10
  • It looks like you have a monorepo do you use something to manage it? Check https://github.com/lerna/lerna. If this is beyond the scope of your project you can use `npm link` to setup a link to some local package https://medium.com/@AidThompsin/how-to-npm-link-to-a-local-version-of-your-dependency-84e82126667a – Yury Tarabanko Oct 12 '21 at 19:45

0 Answers0