Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Possible Bug] Can't run firebase serve/deploy from root dir. #1574

Closed
Industrial opened this issue Jul 31, 2019 · 2 comments
Closed

[Possible Bug] Can't run firebase serve/deploy from root dir. #1574

Industrial opened this issue Jul 31, 2019 · 2 comments

Comments

@Industrial
Copy link

[REQUIRED] Environment info

firebase-tools: 7.2.2

Platform: Ubuntu

[REQUIRED] Test case

I can't seem to run firebase serve/deploy from the git root directory. I would like to place all config files in here and not in the functions subdirectory. This will enable linting/fixing on my test code, among other things.

[REQUIRED] Steps to reproduce

$ mv functions/.* .
$ mv functions/tsconfig.json .
$ mv functions/node_modules functions/yarn* .

$ ./node_modules/.bin/firebase serve --only functions,hosting

[REQUIRED] Expected behavior

Deploy / Serve

[REQUIRED] Actual behavior

[2019-07-31T08:26:40.945Z] ----------------------------------------------------------------------
[2019-07-31T08:26:40.948Z] Command:       /home/tom/.nvm/versions/node/v10.16.0/bin/node /home/tom/Code/Code9/small-crypto/node_modules/.bin/firebase serve --only functions,hosting --debug
[2019-07-31T08:26:40.949Z] CLI Version:   7.2.2
[2019-07-31T08:26:40.949Z] Platform:      linux
[2019-07-31T08:26:40.949Z] Node Version:  v10.16.0
[2019-07-31T08:26:40.949Z] Time:          Wed Jul 31 2019 10:26:40 GMT+0200 (Central European Summer Time)
[2019-07-31T08:26:40.949Z] ----------------------------------------------------------------------

[2019-07-31T08:26:40.956Z] > 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-07-31T08:26:40.957Z] > authorizing via signed-in user
[2019-07-31T08:26:40.957Z] [iam] checking project small-crypo for permissions ["firebase.projects.get"]
[2019-07-31T08:26:40.959Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/small-crypo:testIamPermissions
 permissions=[firebase.projects.get]
[2019-07-31T08:26:42.044Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Wed, 31 Jul 2019 08:26:41 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=721, alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-07-31T08:26:42.049Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/small-crypo

[2019-07-31T08:26:42.649Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Wed, 31 Jul 2019 08:26:42 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-07-31T08:26:42.656Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/small-crypo/webApps/-/config

[2019-07-31T08:26:42.660Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at validateString (internal/validators.js:125:11)
    at Object.join (path.js:1147:7)
    at new FunctionsEmulator (/home/tom/Code/Code9/small-crypto/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:43:34)
    at Object.<anonymous> (/home/tom/Code/Code9/small-crypto/node_modules/firebase-tools/lib/serve/functions.js:39:71)
    at Generator.next (<anonymous>)
    at /home/tom/Code/Code9/small-crypto/node_modules/firebase-tools/lib/serve/functions.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/home/tom/Code/Code9/small-crypto/node_modules/firebase-tools/lib/serve/functions.js:3:12)
    at Object.start (/home/tom/Code/Code9/small-crypto/node_modules/firebase-tools/lib/serve/functions.js:16:16)
    at /home/tom/Code/Code9/small-crypto/node_modules/firebase-tools/lib/serve/index.js:15:23

Error: An unexpected error has occurred.

Is it possible to automatically detect this path?

gr,

Tom

@Industrial
Copy link
Author

I fixed it with

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "source": ".",
    "predeploy": ["yarn lint:fix", "yarn build"]
  },
  "hosting": {
    "public": "functions/lib/client",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "destination": "app"
      }
    ]
  }
}

Is this behaviour documented somewhere?

leaving this ticket open for the question :-)

gr,

Tom

@samtstern
Copy link
Contributor

@Industrial glad you fixed it! Yes the functions.source configuration parameter is documented here (and I think in some other places):
https://firebase.google.com/docs/functions/manage-functions

The default value is "functions" so what you did is the correct change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants