I was trying to write a simple desktop app with electron and nodejs. The code is simple as shown below.
const {app, BrowserWindow} = require('electron');
// Global reference of the window object.
let mainWindow;
app.on('ready', () => {
mainWindow = new BrowserWindow({ width: 700, height: 600 });
mainWindow.loadURL(`file://${__dirname}/index.html`);
mainWindow.openDevTools();
});
within "index.html"
<script>require('./model.js')</script>
I used knockout binding as follows.
function AppViewModel()
{
// some bindings here ..
this.generate = function()
{
if(...)
{
this.hint("Please fill all fields!");
return;
}
else
{
var json2csv = require('json2csv'); //cannot find this
// planning to use json2csv
...
}
};
}
ko.applyBindings(new AppViewModel());
This was working until I try to use "json2csv" in "generate" function. it just keep saying cannot find it "json2csv".
I tried some solutions people suggested, but none worked. I tried to load different modules there, it keep saying could not find them. How can I fix that problem and use "json2csv"?
Thanks in advance!
via alim
No comments:
Post a Comment