firebase config file.
here I am declaring my firebase configuration file, I am trying to initialize firebase firestore, database for one of my electron application, in the separate firebaseConfig.js file
const {initializeApp} = firebase;
const firebaseConfig = {
setting all the configs here..
}
>here I am exporting the storage and db variables to be used in the main.js electron file where I have written a function to put the data to firebase
const storage = firebase.storage();
const db = firebase.firestore()
module.exports = storage;
module.exports = db;
main.js electron/node js file
below is the main.js file, where I am importing the variables that I have exported from the firebase config file
const storage = require('./firebase/firebaseconfig.js')
const db = require('./firebase/firebaseconfig.js');
function where firebase is being used, here I am supposed to use the storage and db variables that I have exported from the firebaseConfig file..
screenshot({format: 'png'})
.then((image)=>{
dns.lookup("www.google.com")
.then(()=>{
const uploadTask = storage.ref(`screenshots/${image.name}`).put(image);
uploadTask.on(
()=>{
storage
.ref("screenshots")
.child(image.name)
.getDownloadURL()
.then((url)=>{
db.collection("screenshots").add({
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
fieldName: image.name
});
})
}
)
})
.catch(()=>{
fs.writeFile(path.join(myFolderPath, `new_screenshot_${counter}.png`),image,
(err)=>{0
if(err){
console.log(err)
}else{
console.log('screenshot saved!');
counter++;
}
});
})
})
.catch(err => console.log(err));
}
now the problem is, with using firebase for node.js application.. I am being prompted with an error that states No "exports" main defined in C:\Users\screenshot_application\node_modules\firebase\package.json