Electron Cannot find module on production build


#1

I’m new in electron. I have an electron project that uses webpack, typeorm, and react.

This code below will works on development mode.

<div id="root"></div>
    <script>
      {
        const typeorm = require('typeorm')
        typeorm.createConnection()
        window.typeorm = typeorm
      }
    </script>

But after I build my electron app into an executable app (.exe for example) it throws an error on the console developer tools.

Uncaught Error: Cannot find module 'typeorm'

enter image description here

Is there any ways to expose typeorm module?