2

I am following the Cloud Functions tutorial in order to learn how to use Firebase Functions. It all went nice and dandy until the stage I needed to deploy to the cloud - for some reason, I got a syntax exception! It seems the exception is caused by a lambda function:

$ firebase deploy --only functions

=== Deploying to 'my-project-87547'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint E:\Users\Emmet\Documents\firebase_tutorial\functions
> eslint .


E:\Users\Emmet\Documents\firebase_tutorial\functions\index.js
  10:65  error  Parsing error: Unexpected token =>

✖ 1 problem (1 error, 0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ 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\Emmet\AppData\Roaming\npm-cache\_logs\2021-03-31T16_31_27_784Z-debug.log
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm --prefix "%RESOURCE_DIR%" run lint ENOENT
    at notFoundError (C:\Users\Emmet\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\Emmet\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\Emmet\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Users\Emmet\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn npm --prefix "%RESOURCE_DIR%" run lint',
  path: 'npm --prefix "%RESOURCE_DIR%" run lint',
  spawnargs: []
}

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

What's really weird is that I am using verbatim the index.js provided in the tutorial itself, and also it passed successfully and as expected in the Firebase Local Emulator Suite.

For reference, I am running all my commands from a Git Bash terminal (with Administrator) from a Windows 10 PC. My npm version is 6.14.11 and my NodeJS version is v14.16.0.

I know others have experienced similar issues, but I haven't seen anyone get it with the tutorial script itself. Thanks in advance!

2 Answers 2

4

I've had similar experience. What ended up working for me was changing "lint": "eslint .", to "lint": "eslint", Inside package.json.

I suspect it is due to running the project in a Windows machine.

Credit goes to this response: https://stackoverflow.com/a/68423649/15719518

0

"If you are using Windows, you may encounter problems with eslint. To fix this problem (if you don't want to use eslint):

  1. Delete the functions folder.
  2. Run 'firebase init functions'.
  3. Answer 'yes' to all prompts, except for the 'use eslint' option which should be marked as 'NO'.
  4. Listen for the confirmation that your firebase deploy is running. :)

Many recommend removing the dot from "lint" : "eslint ." but it is wrong because eslint would not be running correctly and the package would be installed without being able to use it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.