Firebase-functions: Firebase Cloud Functions Deploy Fails After Update to 2.2.0

Created on 1 Feb 2019  ยท  11Comments  ยท  Source: firebase/firebase-functions

[REQUIRED] Version info

"firebase-admin": "^7.0.0",
"firebase-functions": "^2.2.0",
"firebase-tools": "6.3.1"

On running firebase deploy --only functions:

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

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

Updated firebase-admin from 6.5.1 -> 7.0.0
Updated firebase-functions from 2.1.0 -> 2.2.0

[REQUIRED] Expected behavior

Successfully deploy cloud function.

[REQUIRED] Actual behavior

Cannot deploy to cloud functions:
Error: functions predeploy error: Command terminated with non-zero exit code2

firebase.json =>

{ "functions": { "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint", "npm --prefix \"$RESOURCE_DIR\" run build" ], "source": "functions" } }

package.json =>

{ "name": "functions", "scripts": { "lint": "tslint --project tsconfig.json", "build": "tsc", "serve": "npm run build && firebase serve --only functions", "shell": "npm run build && firebase functions:shell", "start": "npm run shell", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log" }, "main": "lib/index.js", "dependencies": { "@sendgrid/client": "^6.3.0", "@sendgrid/mail": "^6.3.1", "async": "^2.6.1", "axios": "^0.18.0", "cors": "^2.8.5", "firebase-admin": "^7.0.0", "firebase-functions": "^2.2.0", "fs-extra": "^7.0.1", "inline-css": "^2.4.1", "nodemailer": "^5.1.1", "xlsx": "^0.14.1" }, "engines": { "node": "8" }, "devDependencies": { "@types/fs-extra": "^5.0.4", "@types/nodemailer": "^4.6.5", "tslint": "~5.8.0", "typescript": "~2.8.3" }, "private": true }

Output of firbase deploy --debug =>

`
[2019-02-01T05:12:43.213Z] ----------------------------------------------------------------------
[2019-02-01T05:12:43.216Z] Command: /Users/Azlan_Mac/.nvm/versions/node/v11.6.0/bin/node /Users/Azlan_Mac/.nvm/versions/node/v11.6.0/bin/firebase deploy --debug
[2019-02-01T05:12:43.217Z] CLI Version: 6.3.1
[2019-02-01T05:12:43.217Z] Platform: darwin
[2019-02-01T05:12:43.217Z] Node Version: v11.6.0
[2019-02-01T05:12:43.218Z] Time: Fri Feb 01 2019 13:12:43 GMT+0800 (Malaysia Time)
[2019-02-01T05:12:43.218Z] ----------------------------------------------------------------------

[2019-02-01T05:12:43.228Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2019-02-01T05:12:43.228Z] > authorizing via signed-in user
[2019-02-01T05:12:43.228Z] [iam] checking project mydaypwaapp for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get","firebasehosting.sites.update"]
[2019-02-01T05:12:43.231Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/mydaypwaapp:testIamPermissions
permissions=[cloudfunctions.functions.create, cloudfunctions.functions.delete, cloudfunctions.functions.get, cloudfunctions.functions.list, cloudfunctions.functions.update, cloudfunctions.operations.get, firebase.projects.get, firebasehosting.sites.update]
[2019-02-01T05:12:44.769Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 01 Feb 2019 05:12:45 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-02-01T05:12:44.771Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/mydaypwaapp

[2019-02-01T05:12:45.378Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 01 Feb 2019 05:12:45 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39", accept-ranges=none, transfer-encoding=chunked

=== Deploying to 'mydaypwaapp'...

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

functions@ lint /Users/Azlan_Mac/Desktop/myDayPwaAppPreRender/functions
tslint --project tsconfig.json

WARNING: /Users/Azlan_Mac/Desktop/myDayPwaAppPreRender/functions/src/index.ts[995, 15]: 'user' is declared but its value is never read.

Running command: npm --prefix "$RESOURCE_DIR" run build

functions@ build /Users/Azlan_Mac/Desktop/myDayPwaAppPreRender/functions
tsc

node_modules/firebase-functions/lib/function-builder.d.ts(60,95): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(60,96): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(60,116): error TS1005: ';' expected.
node_modules/gaxios/build/src/index.d.ts(14,66): error TS1005: '>' expected.
node_modules/gaxios/build/src/index.d.ts(14,103): error TS1109: Expression expected.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: tsc
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ build 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! /Users/Azlan_Mac/.npm/_logs/2019-02-01T05_12_54_031Z-debug.log

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

NPM Debug Log =>

0 info it worked if it ends with ok 1 verbose cli [ '/Users/Azlan_Mac/.nvm/versions/node/v11.6.0/bin/node', 1 verbose cli '/Users/Azlan_Mac/.nvm/versions/node/v11.6.0/bin/npm', 1 verbose cli 'run', 1 verbose cli 'build' ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ] 5 info lifecycle functions@~prebuild: functions@ 6 info lifecycle functions@~build: functions@ 7 verbose lifecycle functions@~build: unsafe-perm in lifecycle true 8 verbose lifecycle functions@~build: PATH: /Users/Azlan_Mac/.nvm/versions/node/v11.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/Azlan_Mac/Desktop/myDayPwaAppPreRender/functions/node_modules/.bin:/Users/Azlan_Mac/.nvm/versions/node/v11.6.0/bin:/Users/Azlan_Mac/.npm-packages/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/bin/libtool:/Users/Azlan_Mac/.npm-packages/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/Azlan_Mac/Desktop/myDayPwaAppPreRender/node_modules/.bin 9 verbose lifecycle functions@~build: CWD: /Users/Azlan_Mac/Desktop/myDayPwaAppPreRender/functions 10 silly lifecycle functions@~build: Args: [ '-c', 'tsc' ] 11 silly lifecycle functions@~build: Returned: code: 2 signal: null 12 info lifecycle functions@~build: Failed to exec build script 13 verbose stack Error: functions@ build:tsc 13 verbose stack Exit status 2 13 verbose stack at EventEmitter.<anonymous> (/Users/Azlan_Mac/.nvm/versions/node/v11.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16) 13 verbose stack at EventEmitter.emit (events.js:188:13) 13 verbose stack at ChildProcess.<anonymous> (/Users/Azlan_Mac/.nvm/versions/node/v11.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:188:13) 13 verbose stack at maybeClose (internal/child_process.js:978:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5) 14 verbose pkgid functions@ 15 verbose cwd /Users/Azlan_Mac/Desktop/myDayPwaAppPreRender/functions 16 verbose Darwin 18.2.0 17 verbose argv "/Users/Azlan_Mac/.nvm/versions/node/v11.6.0/bin/node" "/Users/Azlan_Mac/.nvm/versions/node/v11.6.0/bin/npm" "run" "build" 18 verbose node v11.6.0 19 verbose npm v6.7.0 20 error code ELIFECYCLE 21 error errno 2 22 error functions@ build:tsc 22 error Exit status 2 23 error Failed at the functions@ build script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 2, true ]

deploy

Most helpful comment

Update:

Managed to address the issue.

I updated the typescript package to 3.3.1 and when running the functions build command, it gave a much clearer indication of where the error was originating from. Turns out one of the types dev dependencies in my main angular package.json file did not have a default export which was causing the issue. After removing the types dev dependency, i was able to successfully deploy the functions.

Thank you for your help. ๐Ÿ‘

All 11 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Hi @mazlano27 thanks for the report. I just tried to reproduce this behavior but was able to deploy successfully with the versions you specified for firebase-functions, fiirebase-admin, and firebase-tools. Can you please run firebase deploy --debug and paste your output, as well as your package.json and firebase.json? The error seems to indicate some issue with a predeploy hook - I thought that might mean you're using Typescript and tried to deploy typescript functions as well but that also worked for me.

Hi @mazlano27 thanks for the report. I just tried to reproduce this behavior but was able to deploy successfully with the versions you specified for firebase-functions, fiirebase-admin, and firebase-tools. Can you please run firebase deploy --debug and paste your output, as well as your package.json and firebase.json? The error seems to indicate some issue with a predeploy hook - I thought that might mean you're using Typescript and tried to deploy typescript functions as well but that also worked for me.

Hi @thechenky , thank you for your reply. I have updated the original post with the information you have requested for.

The error appears to be happening in your predeploy script when typescript
is being compiled, and doesn't immediately seem related to the SDK

On Thu, Jan 31, 2019, 9:16 PM mazlano27 notifications@github.com wrote:

Hi @mazlano27 https://github.com/mazlano27 thanks for the report. I
just tried to reproduce this behavior but was able to deploy successfully
with the versions you specified for firebase-functions, fiirebase-admin,
and firebase-tools. Can you please run firebase deploy --debug and paste
your output, as well as your package.json and firebase.json? The error
seems to indicate some issue with a predeploy hook - I thought that might
mean you're using Typescript and tried to deploy typescript functions as
well but that also worked for me.

Hi @thechenky https://github.com/thechenky , thank you for your reply.
I have updated the original post with the information you have requested
for.

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-functions/issues/399#issuecomment-459608902,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAD_mY13EL9Hb6nm2SSrwl3AFBaMgxxks5vI82YgaJpZM4adl8O
.

The error appears to be happening in your predeploy script when typescript is being compiled, and doesn't immediately seem related to the SDK
โ€ฆ
On Thu, Jan 31, 2019, 9:16 PM mazlano27 @.*> wrote: Hi @mazlano27 https://github.com/mazlano27 thanks for the report. I just tried to reproduce this behavior but was able to deploy successfully with the versions you specified for firebase-functions, fiirebase-admin, and firebase-tools. Can you please run firebase deploy --debug and paste your output, as well as your package.json and firebase.json? The error seems to indicate some issue with a predeploy hook - I thought that might mean you're using Typescript and tried to deploy typescript functions as well but that also worked for me. Hi @thechenky https://github.com/thechenky , thank you for your reply. I have updated the original post with the information you have requested for. โ€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#399 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAD_mY13EL9Hb6nm2SSrwl3AFBaMgxxks5vI82YgaJpZM4adl8O .

Any suggestions on how I might identify the issue? The predeploy scripts I have are the default ones which were generated by the firebase CLI and they were working before I updated. Thank you!

Update:

Managed to address the issue.

I updated the typescript package to 3.3.1 and when running the functions build command, it gave a much clearer indication of where the error was originating from. Turns out one of the types dev dependencies in my main angular package.json file did not have a default export which was causing the issue. After removing the types dev dependency, i was able to successfully deploy the functions.

Thank you for your help. ๐Ÿ‘

Hi @mazlano27 ah yes typescript can be a bit tricky, so happy to hear that your issue was resolved! I'm going to close this out now, but feel free to reach out again if you encounter any other issues.

Update:

Managed to address the issue.

I updated the typescript package to 3.3.1 and when running the functions build command, it gave a much clearer indication of where the error was originating from. Turns out one of the types dev dependencies in my main angular package.json file did not have a default export which was causing the issue. After removing the types dev dependency, i was able to successfully deploy the functions.

Thank you for your help. ๐Ÿ‘

This fixed it for me!

Update:

Managed to address the issue.

I updated the typescript package to 3.3.1 and when running the functions build command, it gave a much clearer indication of where the error was originating from. Turns out one of the types dev dependencies in my main angular package.json file did not have a default export which was causing the issue. After removing the types dev dependency, i was able to successfully deploy the functions.

Thank you for your help. ๐Ÿ‘

This worked for me as well. Thanks! ๐Ÿ’ฏ

I am also running into this issue. how did you resolve it.

src/index.ts:1:1 - error TS6133: 'functions' is declared but its value is never read.

1 import * as functions from 'firebase-functions';

import * as functions from "firebase-functions";

Add this following code below the import statement

export const helloWorld = functions.https.onRequest((req, resp) => {
resp.send("Hello from Firebase!");
});

save it and run firebase deploy

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shrestaz picture shrestaz  ยท  5Comments

piuccio picture piuccio  ยท  4Comments

ArbestNew picture ArbestNew  ยท  5Comments

TomClarkson picture TomClarkson  ยท  5Comments

jspri picture jspri  ยท  5Comments