Using 'express' inside Electron main thread, cannot find module Using 'express' inside Electron main thread, cannot find module express express

Using 'express' inside Electron main thread, cannot find module


You can run Express server inside Electron. Here is a sample repo for running express inside Electron.

You can fork a child process to run express app as follows

app = require("electron").remote.app),node = require("child_process").fork(         `${app.getAppPath()}/express-app/bin/www`,         [],         {             stdio: ["pipe", "pipe", "pipe", "ipc"]         });

The express app used here is a generated one using express-generator.

The problem with your approach is that you are maintaining a single package.json file for both Electron and Express. Checkout Electron-React-Boilerplate, here i have two separate npm installation locations one is for Electron alone and other is for React stuffs. Electron-packager and Electron-builder works using this pattern. This is the reason why your process on main thread throws

Error: Cannot find module 'express'