Firebase Cloud Functions Deploy Fails After Update to 2.2.0
See original GitHub issue[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 npm@6.7.0 3 info using node@v11.6.0 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:
tsc13 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:
tsc22 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 ]
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (3 by maintainers)
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.