Firebase-tools: Firebase Deploy Broken after 1.0 Update

Created on 6 Apr 2018  Â·  7Comments  Â·  Source: firebase/firebase-tools

Version info

3.18.1

Platform Information

Linux

Issue

Hello I just did the Functions 1.0 Update and I can no longer run firebase deploy for my database trigger functions.

This is the error I am getting

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: Unexpected token o in JSON at position 1

I did all of the following

npm install firebase-functions@latest --save
npm install [email protected] --save
npm install -g firebase-tools

and my index.js looks like this

const functions = require('firebase-functions')

exports.dbWrite = functions.database.ref('/path').onWrite((change, context) => {
    const beforeData = change.before.val(); // data before the write
    const afterData = change.after.val(); // data after the write
  });

Everything was working fine before I did the npm updates.

Does anyone have any idea what's going on here?

Full Debug

[2018-04-06T03:18:20.065Z] ----------------------------------------------------------------------
[2018-04-06T03:18:20.086Z] Command:       /home/dev/.nvm/versions/node/v6.11.0/bin/node /usr/bin/firebase deploy --debug
[2018-04-06T03:18:20.088Z] CLI Version:   3.18.1
[2018-04-06T03:18:20.088Z] Platform:      linux
[2018-04-06T03:18:20.088Z] Node Version:  v6.11.0
[2018-04-06T03:18:20.089Z] Time:          Fri Apr 06 2018 03:18:20 GMT+0000 (UTC)
[2018-04-06T03:18:20.089Z] ----------------------------------------------------------------------

[2018-04-06T03:18:20.251Z] > 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"]
[2018-04-06T03:18:20.253Z] > authorizing via signed-in user
[2018-04-06T03:18:20.333Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/test-86587

 Fri Apr 06 2018 03:18:20 GMT+0000 (UTC)
[2018-04-06T03:18:21.300Z] <<< HTTP RESPONSE 200 server=nginx, date=Fri, 06 Apr 2018 03:18:21 GMT, content-type=application/json; charset=utf-8, content-length=105, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-04-06T03:18:21.312Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/test-86587/tokens

 Fri Apr 06 2018 03:18:21 GMT+0000 (UTC)
[2018-04-06T03:18:21.711Z] <<< HTTP RESPONSE 200 server=nginx, date=Fri, 06 Apr 2018 03:18:21 GMT, content-type=application/json; charset=utf-8, content-length=258, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-04-06T03:18:47.321Z] > [functions] package.json contents: {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase serve --only functions",
    "shell": "firebase experimental:functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "firebase-admin": "~5.11.0",
    "firebase-functions": "^1.0.0"
  },
  "private": true
}
[2018-04-06T03:18:47.344Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/test-86587?view=CONSUMER_VIEW

 Fri Apr 06 2018 03:18:47 GMT+0000 (UTC)
[2018-04-06T03:18:47.367Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/test-86587?view=CONSUMER_VIEW

 Fri Apr 06 2018 03:18:47 GMT+0000 (UTC)
[2018-04-06T03:18:48.148Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 06 Apr 2018 03:18:48 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35", accept-ranges=none, connection=close
[2018-04-06T03:18:48.258Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 06 Apr 2018 03:18:48 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35", accept-ranges=none, connection=close
[2018-04-06T03:18:48.283Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/test-86587

 Fri Apr 06 2018 03:18:48 GMT+0000 (UTC)
[2018-04-06T03:18:48.623Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 06 Apr 2018 03:18:48 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35", accept-ranges=none, connection=close
[2018-04-06T03:18:48.635Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/978837639091:getServerAppConfig

 Fri Apr 06 2018 03:18:48 GMT+0000 (UTC)
[2018-04-06T03:18:48.996Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 06 Apr 2018 03:18:48 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35", accept-ranges=none, connection=close
[2018-04-06T03:18:49.037Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/test-86587/configs

 Fri Apr 06 2018 03:18:49 GMT+0000 (UTC)
[2018-04-06T03:18:49.380Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 06 Apr 2018 03:18:49 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35", accept-ranges=none, connection=close

Error: Unexpected token o in JSON at position 1

Most helpful comment

having same issue

this is v3.18.1 bug

npm uninstll -g firebase-tools
npm i -g [email protected]

All 7 comments

Having exact same issue.

having same issue

this is v3.18.1 bug

npm uninstll -g firebase-tools
npm i -g [email protected]

@LeoHeo Great! this works for me!

@LeoHeo Thanks! Downgrading to 3.18.0 allowed me to deploy.

Still having issues when running firebase deploy --only functions. Everything was working prior to v1.0.0 release. Followed the migrations steps outlined at https://firebase.google.com/docs/functions/beta-v1-diff.

[email protected]
[email protected]
[email protected]
[email protected]

```[debug] [2018-04-06T16:20:26.210Z] ----------------------------------------------------------------------
[debug] [2018-04-06T16:20:26.213Z] Command: /usr/local/bin/node /usr/local/bin/firebase deploy --only functions
[debug] [2018-04-06T16:20:26.213Z] CLI Version: 3.18.0
[debug] [2018-04-06T16:20:26.213Z] Platform: darwin
[debug] [2018-04-06T16:20:26.213Z] Node Version: v6.11.5
[debug] [2018-04-06T16:20:26.213Z] Time: Fri Apr 06 2018 09:20:26 GMT-0700 (PDT)
[debug] [2018-04-06T16:20:26.213Z] ----------------------------------------------------------------------
[debug]
[debug] [2018-04-06T16:20:26.224Z] > 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"]
[debug] [2018-04-06T16:20:26.225Z] > authorizing via signed-in user
[debug] [2018-04-06T16:20:26.227Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/apitest

Fri Apr 06 2018 09:20:26 GMT-0700 (PDT)
[debug] [2018-04-06T16:20:26.674Z] <<< HTTP RESPONSE 200
[debug] [2018-04-06T16:20:26.675Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/apitest/tokens

Fri Apr 06 2018 09:20:26 GMT-0700 (PDT)
[debug] [2018-04-06T16:20:27.371Z] <<< HTTP RESPONSE 200
[debug] [2018-04-06T16:20:27.662Z] Error: spawn npm ENOENT
at exports._errnoException (util.js:1020:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:32)
at onErrorNT (internal/child_process.js:376:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
[debug] [2018-04-06T16:20:27.664Z] Error: spawn npm ENOENT
at exports._errnoException (util.js:1020:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:32)
at onErrorNT (internal/child_process.js:376:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
[error]
[error] Error: An unexpected error has occurred.
```

Just ran into the same error:

✔  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: Error occurred while parsing your function triggers.

Error: Failed to parse app options file: Error: ENOENT: no such file or directory, open '[object Object]'
    at FirebaseAppError.Error (native)
    at FirebaseAppError.FirebaseError [as constructor] (/usr/local/google/home/hkj/Projects/fireflicks/private/fireflicks-functions/functions/node_modules/firebase-admin/lib/utils/error.js:39:28)
    at FirebaseAppError.PrefixedFirebaseError [as constructor] (/usr/local/google/home/hkj/Projects/fireflicks/private/fireflicks-functions/functions/node_modules/firebase-admin/lib/utils/error.js:85:28)
    at new FirebaseAppError (/usr/local/google/home/hkj/Projects/fireflicks/private/fireflicks-functions/functions/node_modules/firebase-admin/lib/utils/error.js:119:28)
    at FirebaseNamespaceInternals.loadOptionsFromEnvVar (/usr/local/google/home/hkj/Projects/fireflicks/private/fireflicks-functions/functions/node_modules/firebase-admin/lib/firebase-namespace.js:214:19)
    at FirebaseNamespaceInternals.initializeApp (/usr/local/google/home/hkj/Projects/fireflicks/private/fireflicks-functions/functions/node_modules/firebase-admin/lib/firebase-namespace.js:64:28)
    at FirebaseNamespace.initializeApp (/usr/local/google/home/hkj/Projects/fireflicks/private/fireflicks-functions/functions/node_modules/firebase-admin/lib/firebase-namespace.js:362:30)
    at Object.<anonymous> (/usr/local/google/home/hkj/Projects/fireflicks/private/fireflicks-functions/functions/lib/index.js:8:7)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at /usr/local/google/home/hkj/.nvm/versions/node/v6.12.3/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11
    at Object.<anonymous> (/usr/local/google/home/hkj/.nvm/versions/node/v6.12.3/lib/node_modules/firebase-tools/lib/triggerParser.js:38:3)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Had to downgrade tools to deploy the functions.

Just released firebase-tools v3.18.2, which resolves the issue.

Was this page helpful?
0 / 5 - 0 ratings