Changing BrowserWindow URL Unknown stdin file type


#1

Hello, I am new to Electron and am experimenting with it but encountered a problem…

It’s really simple. I want my app to show me a button which when pressed changes the loaded page of my BrowserWindow but I am getting this uncaught error: unknown stdin file type.
I searched for solutions and found some but i didnt really understand them…
I am using electron-prebuilt and here is my code:

main.js

const electron = require('electron')
const {app, BrowserWindow} = electron
let win
app.on('ready', () => {
  win = new BrowserWindow({
    width: 800,
    height: 600,
    minWidth: 800,
    minHeight: 600,
    autoHideMenuBar: true,
    show: false
  })
  win.loadURL(`file://${__dirname}/index.html`)
  win.webContents.openDevTools()
  win.once('ready-to-show', () => {
    win.show()
  })
})
exports.switchTo = () => {
  win.loadURL(`file://${__dirname}/secondpage.html`)
}

index.js

const remote = require('electron').remote
const main = remote.require('./main.js')
const yo = require('yo-yo')
const css = require('dom-css')
let btnNextPage = yo`<button onclick=${main.switchTo}>Next Page</button>`
document.body.appendChild(btnNextPage)

index.html

<html>
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <script>
      require('./index.js')
    </script>
  </body>
</html>

The secondpage.html has just some text in it

Would be really nice if someone would help me