Estou tomando esse erro ao exportar o módulo (interno) timer, to apanhando feio... =S
Alguma ideia de como solucionar esse problema?
Uncaught Error: Cannot find module './timer'
at Module._resolveFilename (module.js:485:15)
at Function.Module._resolveFilename (D:\workspace\pocs\electron-timer\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at file:///D:/workspace/pocs/electron-timer/app/js/render.js:2:15
timer.js
const moment = require('moment');
let seconds;
let time;
let timer;
module.exports = {
start: function(el){
time = moment.duration(el.textContent);
seconds = time.asSeconds();
clearInterval(timer);
timer = setInterval(() => {
seconds++;
el.textContent = this.formatTime(seconds);
}, 1000);
console.log("iniciou!");
},
stop: function(el){
},
formatTime: function(seconds){
return moment().startOf('day').seconds(seconds).format("HH:mm:ss");
}
}
render.js
const { ipcRenderer } = require('electron');
const timer = require('./timer');
let aboutLink = document.querySelector('#about-link');
let playButton = document.querySelector(".play-button");
let timeSpan = document.querySelector(".time-clock");
aboutLink.addEventListener('click', function(){
ipcRenderer.send('open-about-window');
});
let images = ['img/play-button.svg', 'img/stop-button.svg'];
playButton.addEventListener('click', function(){
images = images.reverse();
timer.start(timeSpan);
playButton.src = images[0];
});