I'm still getting acquainted with JavaScript, so please bear with me if this question seems a bit basic. I've been attempting to execute Firebase deploy but keep encountering this error message:
1:1 error Parsing error: Unexpected character ''
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Tino\AppData\Roaming\npm-cache\_logs\2018-07-15T14_22_52_268Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
This is how my index.js file looks like:
const functions = require('firebase-functions');
// replaces keywords with emoji in the "text" key of messages
// pushed to /messages
exports.emojify =
functions.database.ref('/messages/{pushId}/text')
.onWrite(event => {
// Database write events include new, modified, or deleted
// database nodes. All three types of events at the specific
// database path trigger this cloud function.
// For this function we only want to emojify new database nodes,
// so we'll first check to exit out of the function early if
// this isn't a new message.
// !event.data.val() is a deleted event
// event.data.previous.val() is a modified event
if (!event.data.val() || event.data.previous.val()) {
console.log("not a new write event");
return;
}
// Now we begin the emoji transformation
console.log("emojifying!");
// Get the value from the 'text' key of the message
const originalText = event.data.val();
const emojifiedText = emojifyText(originalText);
// Return a JavaScript Promise to update the database node
return event.data.ref.set(emojifiedText);
});
// Returns text with keywords replaced by emoji
function emojifyText(text) {
var emojifiedText = text;
emojifiedText = emojifiedText.replace(/\blol\b/ig, ":D");
emojifiedText = emojifiedText.replace(/\bcat\b/ig, ":D(cat)");
return emojifiedText;
}
The detailed log for C:\Users\Tino\AppData\Roaming\npm-cache_logs\2018-07-15T14_22_52_268Z-debug.log is as follows:
... (log details here)
The code has been borrowed from a tutorial that's about 2 years old, so I'm unsure what might be causing this issue.