Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
176
rated 0 times [  181] [ 5]  / answers: 1 / hits: 19019  / 6 Years ago, sun, july 15, 2018, 12:00:00

I am new to javascript so sorry if this is silly question. Im trying to run Firebase deploy but I end up in 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! [email protected] lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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:UsersTinoAppDataRoamingnpm-cache_logs2018-07-15T14_22_52_268Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code1


My index.js looks like this



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
// Replacing with the regular expression /.../ig does a case-insensitive
// search (i flag) for all occurrences (g flag) in the string
function emojifyText(text) {
var emojifiedText = text;
emojifiedText = emojifiedText.replace(/blolb/ig, :D);
emojifiedText = emojifiedText.replace(/bcatb/ig, :D(cat));
return emojifiedText;
}


And the complete log for C:UsersTinoAppDataRoamingnpm-cache_logs2018-07-15T14_22_52_268Z-debug.log looks like this



0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli '--prefix',
1 verbose cli 'C:\Users\Tino\Desktop\FriendlyChatFunctions\functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle [email protected]~prelint: [email protected]
6 info lifecycle [email protected]~lint: [email protected]
7 verbose lifecycle [email protected]~lint: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~lint: PATH: C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;C:UsersTinoDesktopFriendlyChatFunctionsfunctionsnode_modules.bin;C:ProgramDataOracleJavajavapath;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:sqlite;C:UsersTinoputty;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:Program Files (x86)Bracketscommand;C:WINDOWSSystem32OpenSSH;C:Program Filesnodejs;C:Program FilesJavajre-9.0.4bin;C:UsersTinoAppDataLocalMicrosoftWindowsApps;C:UsersTinoAppDataRoamingnpm
9 verbose lifecycle [email protected]~lint: CWD: C:UsersTinoDesktopFriendlyChatFunctionsfunctions
10 silly lifecycle [email protected]~lint: Args: [ '/d /s /c', 'eslint .' ]
11 silly lifecycle [email protected]~lint: Returned: code: 1 signal: null
12 info lifecycle [email protected]~lint: Failed to exec lint script
13 verbose stack Error: [email protected] lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecycleindex.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd C:UsersTinoDesktopFriendlyChatFunctions
16 verbose Windows_NT 10.0.17134
17 verbose argv C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js --prefix C:\Users\Tino\Desktop\FriendlyChatFunctions\functions run lint
18 verbose node v8.11.3
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] lint: `eslint .`
22 error Exit status 1
23 error Failed at the [email protected] lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]


The code is copy pasted from a tutorial (2 years old) so I dont know what could be wrong.


More From » npm

 Answers
56

It look like UTF-8 BOM in the begin of your file.



If you have notepad++ you can remove it by click to Encoding -> Convert to UTF-8 without BOM:



enter



Read more about BOM


[#53977] Wednesday, July 11, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
theron

Total Points: 168
Total Questions: 93
Total Answers: 94

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
;