I tried like this from main.js
// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
const parser = require('./parser.js');
parser.parseHash(url)
But got error that: parser.parseHash
is not function
// parser.js file
function parseHash(url) {
...
}
Are you exporting parseHash function in parser.js file?
module.exports = {
parseHash,
}
// parser.js
exports.parseHash = function (url) {
...
};
//main.js
const parseHash = require('./parser').parseHash;
parseHash(url)
You need to export the function like this:
// parser.js file
function parseHash(url) {
...
}
module.exports = {
parseHash: parseHash
}
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.