I am doing electron project. In it every tutorial i have watched is adding js in <script> tag i want to separate the js code from html. So i
...
<script type="text/javascript" src="./../scripts/upload.js" ></script>
...
<input onchange="upload()" id='train-button' type="file">File</input>
....
and in js file i
function upload(){
const electron = require('electron');
const {ipcRenderer} = electron;
if (x.files.length == 0) {
alert("Select one or more files.");
}else{
ipcRenderer.send("saveFile",targetFile,destinationPath)
}
}
Now here i am getting error that
Uncaught ReferenceError: require is not defined
but if i define require outside the upload function then it is not running that line and saying
electron is undefined