I have an application running Express, and I am trying to distribute it using electron.
Running electron in debug with this:
/path/to/electron/Electron.app/Contents/MacOS/Electron path-to-my-app
My application runs perfectly fine. Express fires up its server and everything works -- the main window opens correctly using mainWindow.loadUrl('http://localhost:3000/');
When I follow the distribution tutorial (linked before) I copy my application resources to:
/path/to/electron/Electron.app/Contents/Resources/app
But now when I run Electron.app, I see Cannot GET /
in the main window... but I have no idea why.
Any ideas?
My only thought is that process.cwd()
is not correctly helping me define the document root here:
//configure Express to default web requests to /workspace/ folder
expressApp.use(express.static(process.cwd() + '/workspace'));
But if that's the case, I don't know how to get around it.
I have an application running Express, and I am trying to distribute it using electron.
Running electron in debug with this:
/path/to/electron/Electron.app/Contents/MacOS/Electron path-to-my-app
My application runs perfectly fine. Express fires up its server and everything works -- the main window opens correctly using mainWindow.loadUrl('http://localhost:3000/');
When I follow the distribution tutorial (linked before) I copy my application resources to:
/path/to/electron/Electron.app/Contents/Resources/app
But now when I run Electron.app, I see Cannot GET /
in the main window... but I have no idea why.
Any ideas?
My only thought is that process.cwd()
is not correctly helping me define the document root here:
//configure Express to default web requests to /workspace/ folder
expressApp.use(express.static(process.cwd() + '/workspace'));
But if that's the case, I don't know how to get around it.
Share Improve this question edited Feb 11, 2016 at 22:21 arthurakay asked Apr 24, 2015 at 21:10 arthurakayarthurakay 5,6518 gold badges39 silver badges65 bronze badges 1- 1 Can you please provide a working example of electron app that uses mean stack? I would like to learn from that. – Vishal Commented Aug 7, 2016 at 19:56
2 Answers
Reset to default 19It turns out that express
for some reason didn't like my document root mapping.
Rather than using:
//configure Express to default web requests to /workspace/ folder
expressApp.use(express.static(process.cwd() + '/workspace'));
I instead use this:
expressApp.use(express.static(path.join(__dirname, 'workspace')));
Don't use process.cwd
, use process.resourcesPath
instead.