title: How can I import another JS file (which is in the same directory) in a electron JS file
body: <p>I'd like to import "new.js" inside "main.js", using  <code>const new = require("new.js")</code>, i tried also <code>import "./new.js"</code>, but I doesn't want to work.</p>
  
  <p>This is my code if you want to see it</p>
  
  <pre><code>// Modules to control application life and create native browser window
  const { app, BrowserWindow } = require('electron')
  const path = require('path')
  
  function createWindow() {
    // Create the browser window.
    const mainWindow = new BrowserWindow({
      width: 800,
      height: 600,
      webPreferences: {
        preload: path.join(__dirname, 'preload.js'),
        nodeIntegration: true
      }
    })
  
    // and load the index.html of the app.
    mainWindow.loadFile('index.htm')
  
    // Open the DevTools.
    // mainWindow.webContents.openDevTools()
  }
  
  // This method will be called when Electron has finished
  // initialization and is ready to create browser windows.
  // Some APIs can only be used after this event occurs.
  app.whenReady().then(() =&gt; {
    createWindow()
  
    app.on('activate', function () {
      // On macOS it's common to re-create a window in the app when the
      // dock icon is clicked and there are no other windows open.
      if (BrowserWindow.getAllWindows().length === 0) createWindow()
    })
  })
  
  // Quit when all windows are closed.
  app.on('window-all-closed', function () {
    // On macOS it is common for applications and their menu bar
    // to stay active until the user quits explicitly with Cmd + Q
    if (process.platform !== 'darwin') app.quit()
  })
  // In this file you can include the rest of your app's specific main process
  // code. You can also put them in separate files and require them here.
  //password
  </code></pre>
  
  <p>i hope you can help me, please do NOT judge my coding skills, i am still learning.
  Anyway here there is my html and css code too.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --&gt;
    &lt;meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"&gt;
    &lt;meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'"&gt;
    &lt;link rel="stylesheet" href="index.css"&gt;
    &lt;link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400&amp;display=swap" rel="stylesheet"&gt;
    &lt;title&gt;FYco&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;h1&gt;FYco app&lt;/h1&gt;
    &lt;form id="whoAreyou"&gt;
      &lt;label for="whoAreyou"&gt;
        Chi sei?
      &lt;/label&gt;
      &lt;br&gt;
      &lt;select&gt;
        &lt;option value="1"&gt;Federico Santucci&lt;/option&gt;
        &lt;option value="2"&gt;Yuri de Marco&lt;/option&gt;
        &lt;option value="3"&gt;Simone Stroppiana&lt;/option&gt;
        &lt;option value="4"&gt;Edoardo Casali&lt;/option&gt;
        &lt;option value="5"&gt;Guido Betti&lt;/option&gt;
      &lt;/select&gt;
      &lt;br&gt;
      &lt;label for="password"&gt;Password&lt;/label&gt;
      &lt;br&gt;
      &lt;div id="password"&gt;
        &lt;input id="password" type="password"&gt;
      &lt;/div&gt;
      &lt;form id="send"&gt;
        &lt;input id="send" type="submit"&gt;
      &lt;/form&gt;
    &lt;/form&gt;
    &lt;!-- You can also require other files to run in this process --&gt;
    &lt;script src="./renderer.js"&gt;&lt;/script&gt;
    &lt;script src="new.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <pre><code>html, body {
      margin: 0;
      padding: 0;
      background-color: #333;
  }
  
  select {
      text-align: center;
      border: 3px solid #555;
      width: 25em; height: 3em;
      font-family: 'Lato', sans-serif;
      font-style: italic;
  }
  
  h1 {
      color: #f1f1f1;
      font-size: 48px;
      font-family: 'Lato', sans-serif;
      text-align: center;
  }
  
  label {
      text-align: center;
      color: #f1f1f1;
      font-size: 48px;
      font-family: 'Lato', sans-serif;
      font-style: italic;
  }
  
  input[type=password] {
      border: 3px solid #555;
      width: 25em; height: 3em;
  }
  
  input[type=submit] {
      border: 3px solid #555;
      width: 25em; height: 3em;
  }
  /* IDs */
  #password {text-align: center}
  #whoAreyou{text-align: center}
  /*
  font-family: 'Lato', sans-serif;
  */
  </code></pre>
  
  <p>I hope everything of my code is clear to you.</p>