Loading jquery from spawned express


#1

hey guys,
so i’m spawning express webserver from electron, and loading localhost index in browser url, when page loads it can’t find jquery even though its in node_modules for both the express server & electron.
What am I doing wrong?

Main.js

const expressAppUrl = "http://localhost:3000/admin",
spawn = require("child_process").spawn,
node = spawn("node.exe", ["./express/bin/www"]);

let win;
function createWindow() {
    let win = new BrowserWindow({width: 800, height: 600} )
    win.loadURL('http://localhost:3000/admin');
}

index.html

   <script>
        window.$ = window.jQuery = require('jquery');
        </script>

#2

this also doesn’t work…
window.$ = window.jQuery = require(’./node_modules/jquery/dist/jquery.min.js’);


#3

Why are you running a web server to launch an Electron app?


#4

thank you for the reply.
the solution that worked for me (for future generations) is below, i’ll answer your question in a new thread i’ll open because I do have a few questions

Insert this line above script imports

if (typeof module === 'object') {window.module = module; module = undefined;}

Insert this line after script imports

if (window.module) module = window.module;