diego3g / electron-typescript-react

:electron: An Electron boilerplate including TypeScript, React, Jest and ESLint.
1.45k stars 295 forks source link

child_process issue in packaged output #33

Closed georgeneil closed 3 years ago

georgeneil commented 3 years ago

In App.tsx ` const childProcess = require('child_process') const App = () => {

childProcess.exec('npm -v', (error, stdout, stderr) => { if (error) { alert('Error') return } alert(stdout.toString()) })

return ( <>

</> ) }

`

Working fine in Development mode. But getting 'Error' alert while running the packaged output ?

diego3g commented 3 years ago

With the new Electron releases we cannot call Node.js modules directly from renderer process anymore, now you have to use the bridge file to communicate between renderer and main process.

I did a full refactor of the structure to include this option, take a look at 6acba3b654ee6a56ccd591a9fae157e957abd269.