Not able to use webview on windows


#1

I have a simple react app. It uses:

  • react
  • webpack
  • redux
  • css-modules

Was looking for an easy way to wrap a React app into Electron.
Am trying out webview

Have a simple electron app

It works on OSX but not on Windows 10,
Please help.

It opens up the Electron app but nothing is visible in the webview
I have opened devtools in both the Electron renderer process and the webview,
but i do not see any error messages

I have tried:

  1. electro-forge
  2. electron and electron-packager

steps to run the app

install the global dependencies:

  1. install node LTS ie. v6.9.2
  2. install electron-forge with “npm install -g electron-forge”

run the React app:

  1. git clone https://github.com/deepak/react-todo
  2. cd react-todo
  3. npm install
  4. npm start
  5. open “http://localhost:3000/todo” and “http://localhost:3000/” on the browser and checks that it works

run the Electron app:

  1. git clone https://github.com/deepak/electron-webview-todo
  2. cd electron-webview-todo
  3. npm install
  4. npm start (works on OSX but not windows 10)
  5. we are using electron-forge here
  6. try the same with plain Electron at the use-electron-packager-and-not-electron-forge branch

#2

Are you sure that path.join in:

returns the proper path on Windows? The Node path docs suggest there may be times when results vary depending on the OS. In that case you need path.posix.join or path.resolve.


#3

@john Thanks for taking a look

But it does not seem to be a path issue,
as Electron is able to load the html file

But i also tried out different combinations of path as well:

const path = require('path');

console.log("dirname is: ", __dirname);
console.log("filename is: ", __filename);

console.log("path join: ", path.join(__dirname, "../static/index.html"));
console.log("path resolve: ", path.resolve(__dirname, "../static/index.html"));
console.log("path posix ", path.posix.join(__dirname, "../static/index.html"));

It gave the output

dirname is:  C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo\src\main-process
filename is:  C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo\src\main-process\foo.js
path join:  C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo\src\static\index.html
path resolve:  C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo\src\static\index.html
path posix  static/index.html

which is correct and as expected


#4

Fixed it :slight_smile:

I was loading "http://0.0.0.0:3000"
It works when i load “http://localhost:3000/” instead