'Getting ENOENT error when deploying a function for the notifications of my application (Firebase function)
I'm trying to deploy a function to send notifications for my chat application. I get this error shown below, but I can't understand where the it comes from.
Could you help me to understand where the error comes from? Is this a problem with my code in the index.js file?
Here is the error:
index.js :
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.notifyNewMessage = functions.firestore
.document('notifications/{uId}/messages/{messageId}')
.onCreate( async (docSnapshot, context) => {
//************************************Obtener datos de la notificacion
const messageNotification = docSnapshot.data();
////////////extraemos los datos
const uidAuthor = messageNotification['uidAuthor'];
const uidReceiver = messageNotification['uidReceiver'];
const messages = messageNotification['message'];
const typeNotification = messageNotification['type'];
//************************************DECLARAR PROMESAS
const getAuthorData = admin.firestore().doc('users/' + uidAuthor).get();
const getReceiverData = admin.firestore().doc('users/' + uidReceiver).get();
//************************************
const results = await Promise.all([getAuthorData, getReceiverData]);
//************************************
const author = results[0];
const receiver = results[1];
//************************************GET DATA USER AUTHOR
const name = author.get('name');
//************************************GET DATA USER RECEIVER
const tokenNotification = receiver.get('tokenNotification');
//console.log("Datos recogidos USER TO NOTIFY:TOKENS " + tokens);
//////////////////////////////////NOTIFICATION DATA
payload = {
data: {
typeNotif: typeNotification.toString(),
userName: name,
userID: uidAuthor,
message: messages
}
};
admin.messaging().sendToDevice(tokenNotification, payload)
.then(function(response) {
return response;
})
.catch(function(error) {
return error;
});
//////////////////////////////////
});
firebase.js:
{
"functions": {
"predeploy": [
"npm --prefix functions run lint"
]
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

