JavaScript Electron shows white screen when built

I'm learning electron and I've made an electron app that read and create files. When I start the application with "npm start" or "electron ." it works as intended you can see the application here

but when I use the "npm run build" or "build -w" commands the application built just shows a white screen Is there something wrong with my code or something wrong with the commands I'm using?

This is my package.json

 {
  "name": "prova",
  "version": "1.1.3",
  "description": "Prova electron",
  "main": "index.js",
  "scripts": {
    "start": "electron .",
    "dist" : "build"
  },
  "author": "Randy",
  "license": "ISC",
  "devDependencies": {
    "electron": "^2.0.2",
    "electron-packager": "^12.1.0"
  },
  "build": {
    "appId": "prova",
    "win":{
      "target" : "nsis",
      "icon" : "icon.ico"
    }
  }
}

This is my main js page:

const {app, BrowserWindow} = require('electron')
const url = require('url')

function boot(){
    win = new BrowserWindow()
    win.loadURL(url.format({
        pathname: 'index.html',
        slashes: true
    }))
}

app.on('ready', boot);

and there is my functions js page:

var app = require("electron").remote;
var dialog = app.dialog;
var fs = require("fs");
var i = 0;
var stringaLetta = "";

document.getElementById("bottone").onclick = function(){
    dialog.showSaveDialog((fileName) => {
        if(fileName === undefined){
            alert("errore")
            return
        }

        var content = document.getElementById("testo").value;

        fs.writeFile(fileName, content, (err) => {
            if (err == undefined) {
                dialog.showMessageBox({
                    message: "the file has been saved",
                    buttons: ["OK"]
                });
            }
            else dialog.showMessageBox({
                message: err
            })
        })
    })
}
document.getElementById("bottone2").onclick = function(){
    dialog.showOpenDialog((fileNames) => {
        if(fileNames === undefined){
            dialog.showMessageBox({
                message: "errore durante l'apertura",
                buttons: ["OK"]
            })
            return
        } else{
            readFile(fileNames[0]);
        }
    }) 
}

function readFile(fP){
    fs.readFile(fP, 'utf-8', (err, data) => {
        if(err){
            alert(err)
            return
        }
        var textArea = document.getElementById("rtesto")
        textArea.innerHTML = "";
        i = 0;
        do{
            if(data.charAt(i) == "\n"){
                stringaLetta += "<br\>";
            }else{
                stringaLetta += data.charAt(i);
            }
            i++;
        }while(data.charAt(i) != "")
        textArea.innerHTML = stringaLetta;
        stringaLetta = " ";
    })
}
Answer:1

I am new to React. I am trying to display few locations over Google Maps using google-map-react. I am using the below source for it. import React, { Component } from 'react'; import GoogleMapReact ...

I am new to React. I am trying to display few locations over Google Maps using google-map-react. I am using the below source for it. import React, { Component } from 'react'; import GoogleMapReact ...

  1. react array iteration
  2. react array foreach
  3. react array loop
  4. react array foreach render
  5. react array foreach is not a function
  6. react array loop render
  7. react array foreach break
  8. react native array iteration
  9. react js array iteration
  10. react iterate array of objects
  11. react iterate array in render
  12. react iterate array jsx
  13. react iterate array component
  14. react iterate array of strings
  15. react iterate array key
  16. react loop array of objects
  17. react loop array jsx
  18. react loop array map
  19. react loop array of elements

I need a simple way to wait for setTimeout code to finish executing and then run the code that comes after setTimeout. Now the code after loop containing setTimout is executing before loop/setTimout ...

I need a simple way to wait for setTimeout code to finish executing and then run the code that comes after setTimeout. Now the code after loop containing setTimout is executing before loop/setTimout ...

I have a ul with items coming from the loop, and then extra li after that. <ul> <todo-item v-for="(todo,index) in todos" v-bind:todo="todo" :key="index" /> <li :key='"new_item"'>...

I have a ul with items coming from the loop, and then extra li after that. <ul> <todo-item v-for="(todo,index) in todos" v-bind:todo="todo" :key="index" /> <li :key='"new_item"'>...

I have a select tag with 4 options. I want to get a particular option clicked when the page loads and a method should called because of click event. Here what I have tried so far: HTML <select>...

I have a select tag with 4 options. I want to get a particular option clicked when the page loads and a method should called because of click event. Here what I have tried so far: HTML <select>...

  1. click event page
  2. click event on page load
  3. click event on page jquery
  4. click event reload page
  5. click event after page load
  6. click event fires on page load
  7. click event in html page
  8. stop button click event page refresh
  9. trigger click event on page load jquery
  10. trigger click event on page load
  11. call click event on page load jquery
  12. page click event javascript
  13. jquery click event after page load
  14. trigger click event after page load
  15. javascript click event on page load
  16. jquery click event reloads page
  17. angular click event reloads page
  18. button click event on page load c#
  19. button click event reload page
  20. prevent click event on page refresh