I'm trying to load knex
in the preload js script instead of in the Main Process
i have though of importing knex from Main Process using module.exports
you get new errors
/home/alexander/Deve…enderer/init.js:166 Unable to load preload script: /home/alexander/Develop/Electron/App/app/preload.js
/home/alexander/Deve…enderer/init.js:167 TypeError: Cannot read property 'on' of undefined
When i add this in preload:
//preload js
var knex = require("knex")({
client: "sqlite3",
connection: {
filename: path.join(__dirname, './database.sqlite')
},
useNullAsDefault: true
});
I end up with these errors in the electrons app devtools
/home/alexander/Deve…enderer/init.js:166 Unable to load preload script: /home/alexander/Develop/Electron/App/app/preload.js
/home/alexander/Deve…enderer/init.js:167 ReferenceError: path is not defined (anonymous) @ /home/alexander/Deve…enderer/init.js:167
Your error:
ReferenceError: path is not defined
you use path
so try
//preload js
// added path
const path = require("path");
var knex = require("knex")({
client: "sqlite3",
connection: {
filename: path.join(__dirname, './database.sqlite')
},
useNullAsDefault: true
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.