Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
Why cant i require SQLite3 in preload.js?

This is my preload.js file in electron application

window.onload = () => {
  
  const $ = require('jquery');
  //const sqlite3 = require('sqlite3').verbose();
  //const db = new sqlite3.Database(':memory:');
  



  var form_div="";
  document.querySelector("#ppage_btn").addEventListener("click"()={
      
      //console.log("ppage_btn renderer file");
      $('#form-div input').each(function() {
          $(this).attr('value', $(this).val());
      });


      form_div = $("#form-div").clone();
      var elements = document.getElementsByClassName("cats");
      while(elements.length > 0){
          elements[0].parentNode.removeChild(elements[0]);
      }

      var divToPrint = document.getElementById("form-div");
      
      var db_data =  divToPrint.outerHTML;
      db.serialize(function() {
          db.run("CREATE TABLE invoices (codeblock TEXT)");
          var stmt = db.prepare("INSERT INTO invoices VALUES (?)");
          stmt.run(db_data);
          stmt.finalize();
      });

      newWin= window.open("");
      newWin.document.write(divToPrint.outerHTML);
      newWin.print();
      newWin.close();
  });
}

Whenever i un-comment these lines //const sqlite3 = require('sqlite3').verbose(); //const db = new sqlite3.Database(':memory:');
and click on #ppage_btn button to save and print the form ,no error shows and the whole app window crushes .. is there any proper way to add sqlite3 in preload.js file ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!