I am building an Electron application with some HTML that has JavaScript file referenced with a script tag in an HTML form, I am unable to use a node module with require
my function name
function sayhello() {
const path = require('path');
var knex = require("knex")({
client: "sqlite3",
connection: {
filename: path.join(__dir, 'db.sqlite')
}
});
}
How can I reference my node modules in the function?
use nodeIntegration: true
into your electron.js main window container file. If you want to use node.js functionality into renderer file.
like this,
win = new BrowserWindow({
width: 384,
height: 696,
webPreferences: {
devTools: false,
nodeIntegration: true,
preload: path.resolve(path.join(__dirname, "preload.js"))
}
});
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.