Firebase-tools: "ํ•จ์ˆ˜: ํ•จ์ˆ˜ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๋กœ๋“œํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค. ์ตœ์‹  SDK๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค. ...."

์— ๋งŒ๋“  2018๋…„ 01์›” 19์ผ  ยท  60์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: firebase/firebase-tools

๋ฒ„์ „ ์ •๋ณด

> firebase --version
3.17.1
> node --version
v6.12.3
> npm --version
5.6.0

์žฌํ˜„ ๋‹จ๊ณ„

> git clone https://github.com/firebase/functions-samples.git
> cd functions-samples/authenticated-json-api/functions/
> npm install

> [email protected] install /Users/karl/Development/git/learnics/functions-samples/authenticated-json-api/functions/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

[grpc] Success: "/Users/karl/Development/git/learnics/functions-samples/authenticated-json-api/functions/node_modules/grpc/src/node/extension_binary/node-v48-darwin-x64-unknown/grpc_node.node" is installed via remote

> [email protected] postinstall /Users/karl/Development/git/learnics/functions-samples/authenticated-json-api/functions/node_modules/protobufjs
> node scripts/postinstall

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] requires a peer of firebase-admin@~4.2.1 but none is installed. You must install peer dependencies yourself.

added 354 packages in 11.832s
> firebase use my-project
Now using project my-project
> firebase serve --only functions

=== Serving from '/Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api'...

i  functions: Preparing to emulate functions.
โš   functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
โš   functions: Error from emulator. FirebaseError: Error occurred while parsing your function triggers. Please ensure you have the latest firebase-functions SDK by running "npm i --save firebase-functions@latest" inside your functions folder.

Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.
    at init (/Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api/functions/node_modules/firebase-functions/lib/config.js:51:15)
    at Object.config (/Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api/functions/node_modules/firebase-functions/lib/config.js:29:9)
    at Object.<anonymous> (/Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api/functions/index.js:27:31)
    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)

์‹ค์ œ ํ–‰๋™

> firebase serve --only functions --debug
[2018-01-19T03:30:49.455Z] ----------------------------------------------------------------------
[2018-01-19T03:30:49.459Z] Command:       /usr/local/Cellar/node@6/6.12.3/bin/node /usr/local/bin/firebase serve --only functions --debug
[2018-01-19T03:30:49.460Z] CLI Version:   3.17.1
[2018-01-19T03:30:49.460Z] Platform:      darwin
[2018-01-19T03:30:49.460Z] Node Version:  v6.12.3
[2018-01-19T03:30:49.460Z] Time:          Thu Jan 18 2018 22:30:49 GMT-0500 (EST)
[2018-01-19T03:30:49.461Z] ----------------------------------------------------------------------

[2018-01-19T03:30:49.476Z] > 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-01-19T03:30:49.476Z] > authorizing via signed-in user
[2018-01-19T03:30:49.479Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/my-project

 Thu Jan 18 2018 22:30:49 GMT-0500 (EST)
[2018-01-19T03:30:49.855Z] <<< HTTP RESPONSE 200 server=nginx, date=Fri, 19 Jan 2018 03:30:49 GMT, content-type=application/json; charset=utf-8, content-length=126, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-01-19T03:30:49.856Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/my-project/tokens

 Thu Jan 18 2018 22:30:49 GMT-0500 (EST)
[2018-01-19T03:30:50.482Z] <<< HTTP RESPONSE 200 server=nginx, date=Fri, 19 Jan 2018 03:30:50 GMT, content-type=application/json; charset=utf-8, content-length=267, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store

=== Serving from '/Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api'...

i  functions: Preparing to emulate functions.
[2018-01-19T03:30:51.081Z] Fetching environment
[2018-01-19T03:30:51.082Z] >>> HTTP REQUEST GET https://appengine.googleapis.com/v1/apps/my-project

 Thu Jan 18 2018 22:30:51 GMT-0500 (EST)
[2018-01-19T03:30:51.083Z] >>> HTTP REQUEST GET https://apikeys.googleapis.com/v1/projects/my-project/apiKeys

 Thu Jan 18 2018 22:30:51 GMT-0500 (EST)
[2018-01-19T03:30:51.569Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 19 Jan 2018 03:30:51 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=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2018-01-19T03:30:51.663Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 19 Jan 2018 03:30:51 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=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2018-01-19T03:30:51.664Z] Starting @google-cloud/functions-emulator
[2018-01-19T03:30:53.220Z] Parsing function triggers
โš   functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
โš   functions: Error from emulator. FirebaseError: Error occurred while parsing your function triggers. Please ensure you have the latest firebase-functions SDK by running "npm i --save firebase-functions@latest" inside your functions folder.

Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.
    at init (/Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api/functions/node_modules/firebase-functions/lib/config.js:51:15)
    at Object.config (/Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api/functions/node_modules/firebase-functions/lib/config.js:29:9)
    at Object.<anonymous> (/Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api/functions/index.js:27:31)
    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)

๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ์—์„œ firebase serve --only functions ๊ฐ€ ์ •์ง€๋˜๊ณ  ๋‹ค๋ฅธ ์ƒ˜ํ”Œ์„ ๋งŽ์ด ์‹œ๋„ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋งค์šฐ ์ด์ƒํ•ฉ๋‹ˆ๋‹ค. ์–ด๋Š ๊ฒƒ์—์„œ๋„ ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ด๋ฏธ ๋ฐฐํฌํ•œ ๊ธฐ๋Šฅ์—์„œ๋„ ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

firebase serve --only functions ๋Œ€์‹  functions ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€์—์„œ npm run serve ๋ฅผ ์‹คํ–‰ํ•ด ๋ณด์‹ญ์‹œ์˜ค. ์ด๊ฒƒ์€ package.json ํŒŒ์ผ์ด ๊ตฌ์„ฑ๋œ ๋ฐฉ์‹์— ๋”ฐ๋ผ ์ž‘๋™ํ•  ์ˆ˜๋„ ์žˆ๊ณ  ์ž‘๋™ํ•˜์ง€ ์•Š์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  60 ๋Œ“๊ธ€

firebase serve --only functions ๋Œ€์‹  functions ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€์—์„œ npm run serve ๋ฅผ ์‹คํ–‰ํ•ด ๋ณด์‹ญ์‹œ์˜ค. ์ด๊ฒƒ์€ package.json ํŒŒ์ผ์ด ๊ตฌ์„ฑ๋œ ๋ฐฉ์‹์— ๋”ฐ๋ผ ์ž‘๋™ํ•  ์ˆ˜๋„ ์žˆ๊ณ  ์ž‘๋™ํ•˜์ง€ ์•Š์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ถˆํ–‰ํžˆ๋„ ์ด์— ๋Œ€ํ•ด ๊ตฌ์„ฑ๋œ package.json์ด ์—†์Šต๋‹ˆ๋‹ค.

> npm run serve
npm ERR! Darwin 17.3.0
npm ERR! argv "/Users/alchemist/.nvm/versions/node/v6.11.5/bin/node" "/Users/karl/.nvm/versions/node/v6.11.5/bin/npm" "run" "serve"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10

npm ERR! missing script: serve
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/alchemist/Development/git/learnics/functions-samples/authenticated-json-api/functions/npm-debug.log

ํ•˜๋‚˜๋งŒ ์•Œ๋ ค์ค„ ์ˆ˜ ์žˆ๋‹ˆ?

์ด๊ฒƒ์€ ์‹ ์„ ํ•œ firebase init ํ›„์— ๋‚ด ๋ชจ์Šต์ž…๋‹ˆ๋‹ค : https://gist.github.com/dylanjmcdonald/6c033b476e863efaea3eccc0b3137772

3.17.1๋กœ ์—…๋ฐ์ดํŠธํ•œ ํ›„ ์˜ค๋ฅ˜๊ฐ€ ์‹œ์ž‘๋œ ์ดํ›„๋กœ firebase-tools ๋ฅผ 3.16.0์œผ๋กœ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ•˜์—ฌ ์ด ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๋” ๊ธด ์ด์•ผ๊ธฐ

๋‚˜๋Š” ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด ์ตœ์‹  ๋ฒ„์ „์˜ firebase-tools ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์žˆ์—ˆ๋Š”๋ฐ ๋‚ด CI ๋Ÿฌ๋„ˆ์—์„œ ์ด ์˜ค๋ฅ˜๋ฅผ ์ฒ˜์Œ ๋ฐœ๊ฒฌํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฐค์ƒˆ ๋‚ด ๋ฐฐํฌ๊ฐ€ ์ž‘๋™์„ ๋ฉˆ์ท„์Šต๋‹ˆ๋‹ค. firebase-admin ๋ฐ firebase-functions ๋ฅผ ์—…๊ทธ๋ ˆ์ด๋“œํ•œ ํ›„ ๋‹ค์‹œ ์ž‘๋™ํ•˜๊ธฐ ์‹œ์ž‘ํ–ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฌ๋‚˜ ๋‚ด ๋กœ์ปฌ ํ™˜๊ฒฝ์ด ์ž‘๋™์„ ๋ฉˆ์ท„์Šต๋‹ˆ๋‹ค. ์—ฌ์ „ํžˆ ๋ฐฐํฌํ•  ์ˆ˜ ์žˆ์—ˆ์ง€๋งŒ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•  ์ˆ˜๋Š” ์—†์—ˆ์Šต๋‹ˆ๋‹ค. firebase-tools ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ๋‹ค์‹œ ์„ค์น˜ํ•˜๋ ค๊ณ  ์‹œ๋„ํ–ˆ์Šต๋‹ˆ๋‹ค... ๊ทธ๋ฆฌ๊ณ  ๋‚ด๊ฐ€ ์ƒ๊ฐํ•ด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ๋ณ€ํ˜•(์บ์‹œ ์ •๋ฆฌ, ์ตœ์‹  NPM ์‚ฌ์šฉ, 6.11.5 ์‚ฌ์šฉ, Yarn ์‚ฌ์šฉ ๋“ฑ). ๋ถˆ์šด.

๋งˆ์ง€๋ง‰์œผ๋กœ ๋ชจ๋“  ๊ฒƒ์„ ์ด์ „์— ์ž‘๋™ํ•˜๋˜ ๋ฒ„์ „์œผ๋กœ ๋กค๋ฐฑํ•˜๊ณ  CI ์Šคํฌ๋ฆฝํŠธ์— ์‚ฌ์šฉ๋œ ๋ฒ„์ „์„ ๊ณ ์ •ํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ์Šต๋‹ˆ๋‹ค(์ตœ์‹  ๋Œ€์‹ ). ์ด์ œ ๋‘ ํ™˜๊ฒฝ ๋ชจ๋‘ ์ผ๊ด€๋˜๊ฒŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

๋‚˜๋Š” ๋ช‡ ๋‹ฌ ์ „์— ๋‹ค๋ฅธ ๊ฐ€๋Šฅํ•œ ์†”๋ฃจ์…˜์œผ๋กœ ์ด ๋ฌธ์ œ์˜ ๋‹ค์–‘ํ•œ ๋ณ€ํ˜•์„ ๋ณด์•˜์Šต๋‹ˆ๋‹ค. ํ‡ด๋ณด๊ฐ€ ์•„๋‹๊นŒ? ๋ถˆ๋ถ„๋ช…ํ•œ ๊ทผ๋ณธ์ ์ธ ๋ฌธ์ œ?

BTW: ์ €๋Š” macOS High Sierra 10.13.2๋ฅผ ๋กœ์ปฌ๋กœ ์‹คํ–‰ํ•˜๊ณ  ์žˆ์œผ๋ฉฐ ๋„์›€์ด ๋˜๋Š” ๊ฒฝ์šฐ GitLab์—์„œ CI ์‹คํ–‰๊ธฐ๋ฅผ ์œ„ํ•œ node:latest Docker ์ด๋ฏธ์ง€๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

์ถ”์‹ : ์ œ ๊ฒฝํ—˜์ƒ npm run dev ๋Š” ๋‚ด๋ถ€์ ์œผ๋กœ firebase serve --only functions $๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

@rafasoares : ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. 3.16.0์œผ๋กœ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ์ˆ˜์ •๋˜์—ˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

npm install -g [email protected]

macOS High Sierra 10.13.2๋„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์ง€๋งŒ nvm ๋ฅผ ํ†ตํ•ด ์„ค์น˜๋œ ๋…ธ๋“œ v6.11.5๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

@-์—ฐ๊ธˆ์ˆ ์‚ฌ๋‹˜, ์ œ๊ฐ€ ๋„์™€๋“œ๋ฆด ์ˆ˜ ์žˆ์–ด์„œ ๊ธฐ์ฉ๋‹ˆ๋‹ค.

brew(9.x)๋ฅผ ํ†ตํ•ด ์„ค์น˜๋œ ์ตœ์‹  ๋…ธ๋“œ์™€ nvm์„ ํ†ตํ•ด ์„ค์น˜๋œ 6.11.5๋ฅผ ๋ชจ๋‘ ์‚ฌ์šฉํ•ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์ด์ „์—๋Š” ์ตœ์‹  ๋…ธ๋“œ์—์„œ ์ž‘๋™ํ–ˆ์Šต๋‹ˆ๋‹ค(GCP ๋…ธ๋“œ ๋ฒ„์ „ ๊ฒฝ๊ณ ์™€ ํ•จ๊ป˜).

์•ˆ๋…•ํ•˜์„ธ์š” ์—ฌ๋Ÿฌ๋ถ„, ์ตœ์‹  firebase-tools(3.17.1)์—๋„ ์ตœ์‹  firebase-functions SDK๊ฐ€ ํ•„์š”ํ•˜๋ฏ€๋กœ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋” ์ข‹์€ ๋ฐฉ๋ฒ•์€ functions ํด๋” ๋‚ด์—์„œ "npm i --save firebase -functions@latest "๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€์—์„œ ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด ๋ฐฐํฌ ๋˜๋Š” ์ œ๊ณตํ•˜๊ธฐ ์ „์—

@laurenzlong ์œ„์˜ ๋‚ด ์˜๊ฒฌ์„ ์ฝ์—ˆ์Šต๋‹ˆ๊นŒ? ๊ฐ€์žฅ ๋จผ์ € ์‹œ๋„ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ ํ›„, ๋‚˜๋Š” firebase deploy --only functions ํ•  ์ˆ˜ ์žˆ์—ˆ์ง€๋งŒ firebase serve --only functions ํ•  ์ˆ˜ ์—†์—ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ๋‚ด๊ฐ€ ์ƒ๊ฐํ•ด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ์ข…๋ฅ˜์˜ ์ •๋ฆฌ ์ „๋žต์„ ์‹œ๋„ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ž‘์—… ๋ณต์‚ฌ๋ณธ์„ ์‚ญ์ œํ•˜๊ณ  Git์—์„œ ๋ชจ๋“  ๊ฒƒ์„ ์ฒ˜์Œ๋ถ€ํ„ฐ ๊ฐ€์ ธ์™”์Šต๋‹ˆ๋‹ค.

@rafasoares ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ๋ถ€๋ถ„์„ ๋†“์ณค์Šต๋‹ˆ๋‹ค. ์ง€๊ธˆ๋ถ€ํ„ฐ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

์—„์ฒญ๋‚œ! ๊ฐ์‚ฌ ํ•ด์š”!

v3.17.2๊ฐ€ ์ด์ œ ๋ฆด๋ฆฌ์Šค๋˜์—ˆ์œผ๋ฉฐ ๋ฌธ์ œ๋ฅผ ์ˆ˜์ •ํ–ˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ•ด๊ฒฐ๋˜์ง€ ์•Š์œผ๋ฉด ์•Œ๋ ค์ฃผ์‹ญ์‹œ์˜ค. ์‹ ๊ณ ํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

๋ฐฉ๊ธˆ v3.17.2๋ฅผ ์‹œ๋„ํ–ˆ๋Š”๋ฐ ์ €์—๊ฒŒ ํšจ๊ณผ์ ์ด์—ˆ์Šต๋‹ˆ๋‹ค!

๊ทธ๊ฒƒ์€ ๋‚˜๋ฅผ ์œ„ํ•ด ์ž‘๋™ํ•˜์ง€ ์•Š์•˜๋‹ค. ๋‚˜๋Š” ๋นˆ ํ”„๋กœ์ ํŠธ์—์„œ ์ž‘๋™ํ•˜๋„๋ก ๊ด€๋ฆฌํ–ˆ์ง€๋งŒ ํ˜„์žฌ ํ”„๋กœ์ ํŠธ๋ฅผ ์ž‘๋™์‹œํ‚ค์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์ฑ„๊ตดํ•˜๋Ÿฌ ๊ฐ”์Šต๋‹ˆ๋‹ค. ๋‘˜์˜ ์ฐจ์ด์ ์€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?

๋ฌธ์ œ๋ฅผ ์ •ํ™•ํžˆ ์ง€์ ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ์ค‘๋‹จ๋ฉ๋‹ˆ๋‹ค.

const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase); // <-- Specifically, this line

์ดˆ๊ธฐํ™” ๋น„ํŠธ๋ฅผ ์ œ๊ฑฐํ•˜๋ฉด ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ Firestore๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

์—…๋ฐ์ดํŠธ: functions.config().firebase ํ˜ธ์ถœ์„ ๋‹ค์Œ JSON์œผ๋กœ ๋ฐ”๊พธ๋ฉด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

{
  databaseURL: 'https://[PROJECT_NAME].firebaseio.com',
  storageBucket: '[PROJECT_NAME].appspot.com',
  apiKey: '[API KEY]',
  authDomain: '[PROJECT_NAME].firebaseapp.com',
  projectId: '[PROJECT_NAME]',
  credential: admin.credential.applicationDefault()
}

๊ทธ JSON์€ [email protected] $๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ functions.config().firebase ์˜ ์ถœ๋ ฅ์ด์—ˆ์Šต๋‹ˆ๋‹ค(๋ฌธ์„œ์—์„œ ๊ฐ€์ ธ์˜จ credential ๋น„ํŠธ ์ œ์™ธ).

ํ•˜์ง€๋งŒ ์ด ์ฝ”๋“œ๋กœ ๋ฐฐํฌ๋ฅผ ์‹œ๋„ํ•˜์ง€๋Š” ์•Š์•˜์Šต๋‹ˆ๋‹ค.

@rafasoares google-cloud/functions-emulator ์ข…์†์„ฑ์„ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ–ˆ๋Š”๋ฐ ์ฐจ์ด์ ์ž…๋‹ˆ๋‹ค. "npm uninstall -g firebase-tools & npm i -g firebase-tools"๋ฅผ ์‹œ๋„ํ•˜์‹ญ์‹œ์˜ค. ๊ฐ€์ง€๊ณ  ์žˆ๋Š” npm ๋ฒ„์ „์— ๋”ฐ๋ผ ๋จผ์ € ์ œ๊ฑฐ๋ฅผ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š๋Š” ํ•œ ์ข…์†์„ฑ์„ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

@rafasoares semver ๋ฒ„์ „ ๊ด€๋ฆฌ๊ฐ€ ์ž˜๋ชป๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. #618์—์„œ ์ˆ˜์ •ํ•œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ถ„๊ธฐ๋ฅผ ์‚ฌ์šฉํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

npm ์„ค์น˜ -g https://github.com/firebase/firebase-tools.git#laurenzlong -patch-1

@laurenzlong

semver ๋ฒ„์ „ ๊ด€๋ฆฌ๊ฐ€ ์ž˜๋ชป๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. #618์—์„œ ์ˆ˜์ •ํ•œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ถ„๊ธฐ๋ฅผ ์‚ฌ์šฉํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

@rafasoares ์™€ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๊ณ  npm install -g https://github.com/firebase/firebase-tools.git#laurenzlong-patch-1 ์‹œ๋„ํ–ˆ์ง€๋งŒ ๋ฌธ์ œ๊ฐ€ ๋‚จ์•„ ์žˆ์Šต๋‹ˆ๋‹ค.

npm install -g [email protected] ํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋ฉ๋‹ˆ๋‹ค.

์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค. Yarn๊ณผ NPM์ด ์˜ฌ๋ฐ”๋ฅธ ๋ฒ„์ „์„ ๋‹ค์šด๋กœ๋“œํ•˜๋„๋ก ํ•˜๋ ค๊ณ  ์• ์“ฐ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ œ ํ™˜๊ฒฝ์„ ์—‰๋ง์œผ๋กœ ๋งŒ๋“  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ํ•˜ํ•˜.

๊ทธ๋Ÿฌ๋‚˜ ์˜ˆ, https://github.com/firebase/firebase-tools.git#laurenzlong -patch-1์€ @google-cloud/[email protected] ๊ฐ€ ์„ค์น˜๋œ ๋ฒ„์ „์ž„์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ์—ฌ์ „ํžˆ ์˜ค๋ฅ˜๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

@mono0926 @rafasoares ์ด๊ฑด ์–ด๋•Œ์š”?
npm ์„ค์น˜ -g https://github.com/firebase/firebase-tools.git#ll -fixemu

์ธ๋‚ด์‹ฌ๊ณผ ๋„์›€์— ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

@laurenzlong

npm ์„ค์น˜ -g https://github.com/firebase/firebase-tools.git#ll -fixemu

๋ถˆํ–‰ํžˆ๋„ ์ด๊ฒƒ์€ ์—ฌ์ „ํžˆ โ€‹โ€‹๋‚˜์—๊ฒŒ ์˜ค๋ฅ˜๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค :(

npm uninstall -g firebase-tools && npm install -g https://github.com/firebase/firebase-tools.git#ll-fixemu ๋Š” ์–ด๋–ป์Šต๋‹ˆ๊นŒ?

@laurenzlong

npm uninstall -g firebase-tools && npm install -g https://github.com/firebase/firebase-tools.git#ll -fixemu

๋‚˜๋Š” ์ด๋ฏธ ๊ทธ๊ฒƒ์„ ์‹œ๋„ํ–ˆ๋‹ค.

๋ถ„๋ช…ํžˆ https://github.com/firebase/firebase-tools.git#ll -fixemu๊ฐ€ ๋‚˜๋ฅผ ์œ„ํ•ด ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.

$ yarn global remove firebase-tools
yarn global v1.3.2
[1/2] Removing module firebase-tools...
[2/2] Regenerating lockfile and installing missing dependencies...
success Uninstalled packages.
โœจ  Done in 3.91s.
$ yarn global add https://github.com/firebase/firebase-tools.git\#ll-fixemu
yarn global v1.3.2
[1/4] ๐Ÿ”  Resolving packages...
warning https://github.com/firebase/firebase-tools.git#ll-fixemu > universal-analytics > [email protected]: Use uuid module instead
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Installed "[email protected]" with binaries:
      - firebase
โœจ  Done in 11.73s.
$ firebase --version
3.17.2
$ firebase serve --only functions

=== Serving from '/Users/[USERNAME]/dev/projects/[PROJECT NAME]'...

i  functions: Preparing to emulate functions.
โœ”  functions: createUrl: http://localhost:5000/[PROJECT NAME]/us-central1/createUrl
โœ”  functions: getUrl: http://localhost:5000[PROJECT NAME]us-central1/getUrl

ํ˜„์žฌ ๋…ธ๋“œ v6.11.5๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. @mono0926 ์•„๋งˆ๋„ ๊ทธ๊ฒƒ๊ณผ ๊ด€๋ จ์ด ์žˆ์Šต๋‹ˆ๊นŒ?

@rafasoares

ํ˜„์žฌ ๋…ธ๋“œ v6.11.5๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. @mono0926 ์•„๋งˆ๋„ ๊ทธ๊ฒƒ๊ณผ ๊ด€๋ จ์ด ์žˆ์Šต๋‹ˆ๊นŒ?

๊ฐ™์€ ๋ฒ„์ „์˜ ๋…ธ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค ๐Ÿค”

@mono0926 ๋„ค, ๊ทธ๋ƒฅ ์ถ”์ธกํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฐฉ๊ธˆ ์ตœ์‹ ์„ ์‚ฌ์šฉํ•ด ๋ณด์•˜๊ณ  ์ž‘๋™ํ–ˆ์Šต๋‹ˆ๋‹ค.

์ „์—ญ ์ข…์†์„ฑ์„ ์ฒ ์ €ํžˆ ์ •๋ฆฌํ•˜๊ณ  ์บ์‹œ๋ฅผ ์ •๋ฆฌํ•˜์‹ญ์‹œ์˜ค(๋˜ํ•œ ํ”„๋กœ์ ํŠธ์˜ ๋กœ์ปฌ ์ข…์†์„ฑ์„ ๋‹ค์‹œ ๋นŒ๋“œํ•ด ๋ณด์‹ญ์‹œ์˜ค). ์˜ค๋Š˜ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋™์•ˆ ์—ฌ๋Ÿฌ ๋ฒˆ ํ•ด๋ณด์•˜๋Š”๋ฐ ๋„์›€์ด ๋˜์—ˆ์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

@rachelmyers @laurenzlong

npm install -g https://github.com/firebase/firebase-tools.git#ll-fixemu ์‹œ๋„ํ•œ ํ›„ ์˜ค๋ฅ˜ ์„ธ๋ถ€ ์ •๋ณด๊ฐ€ ๋ณ€๊ฒฝ๋œ ๊ฒƒ์„ ์•Œ์•˜์Šต๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์ œ ์ฝ”๋“œ์—์„œ ์—๋Ÿฌ๊ฐ€ ๋‚˜์„œ ์ˆ˜์ •ํ–ˆ๋”๋‹ˆ ์—๋Ÿฌ๊ฐ€ ํ•ด๊ฒฐ๋˜๋„ค์š” ๐Ÿ‘

[email protected] ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ  ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
๊ทธ๋ž˜์„œ ๋‚˜์ค‘์— ๋ง์”€๋“œ๋ฆฌ์ฃ . ๋ฌธ์ œ ์„ธ๋ถ€์‚ฌํ•ญ์„ ์กฐ์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค.

@mono0926 ์ฝ”๋“œ์—์„œ ๋ณ€๊ฒฝํ•œ ์‚ฌํ•ญ์„ ๊ณต์œ ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? Firebase์™€ ๊ด€๋ จ๋œ ๊ฒƒ์ด์—ˆ๋‚˜์š”?

@rachelmyers @laurenzlong

๋‚˜๋Š” ๊ทธ๊ฒƒ์„ ์กฐ์‚ฌํ•˜๊ณ  ๋‚˜๋Š” ์š”์ ์„ ์•Œ์•„ ๋ƒˆ์Šต๋‹ˆ๋‹ค.

์ด ์ฝ”๋“œ๋กœ,

import * as functions from 'firebase-functions';
import * as util from 'util';
console.error(`environment: ${util.inspect(functions.config().environment.project_id)}`);

์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

TypeError: Cannot read property 'project_id' of undefined

ํ•˜์ง€๋งŒ ์ด ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด

import * as functions from 'firebase-functions';
import * as util from 'util';
console.error(`environment: ${util.inspect(functions.config().environment)}`);

์ด ๋กœ๊ทธ๊ฐ€ ์ธ์‡„๋ฉ๋‹ˆ๋‹ค.

info: environment: { project_id: 'development' }

์ตœ์‹  ๋ฒ„์ „์—์„œ project_id of functions.config().environment ์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์—†๋Š” ์ด์œ ๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?
[email protected] $ ์•„๋ž˜์˜ $ project_id of functions.config().environment ์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๋‚˜๋Š” ์ด๊ฒƒ์ด ์ด ๋ฌธ์ œ์˜ ๋˜ ๋‹ค๋ฅธ ๋ฌธ์ œ๋ผ๋Š” ๊ฒƒ์„ ์•Œ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

์ฝ”๋“œ์—์„œ ๋ณ€๊ฒฝํ•œ ์‚ฌํ•ญ์„ ๊ณต์œ ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? Firebase์™€ ๊ด€๋ จ๋œ ๊ฒƒ์ด์—ˆ๋‚˜์š”?

์ž„์‹œ๋กœ project_id ๊ฐ’์„ ํ•˜๋“œ์ฝ”๋”ฉํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์˜€์œผ๋‹ˆ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ด ์ฃผ์…จ์œผ๋ฉด ํ•ฉ๋‹ˆ๋‹ค.

ํ•จ์ˆ˜๋ฅผ ๋ฐฐํฌํ–ˆ์„ ๋•Œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

@The-Alchemist ์ €๋„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค: 3.16.0์œผ๋กœ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค!

npm install -g [email protected]

์ €๋Š” macOS High Sierra 10.13.2๋„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์œผ๋ฉฐ ๊ณ ์ • ๊ถŒํ•œ์œผ๋กœ ์„ค์น˜ ํ”„๋กœ๊ทธ๋žจ์ด ์„ค์น˜ํ•œ ๋…ธ๋“œ v8.9.4: https://docs.npmjs.com/getting-started/fixing-npm-permissions.

Windows์˜ [email protected] ์—๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

๋‚˜๋Š” ์–ป๋‹ค :

+ [email protected]
updated 1 package in 50.957s
(xenial)marcus<strong i="6">@localhost</strong>:~/app$  firebase serve --only functions

=== Serving from '/home/marcus/app'...

โš   functions: Cannot start emulator. Error: Cannot find module '/usr/lib/node_modules/firebase-tools/node_modules/grpc/src/node/extension_binary/grpc_node.node'

๋งˆ์ปค์Šค: --only functions (๋ณต์ˆ˜ํ˜•)

2018๋…„ 1์›” 20์ผ ํ† ์š”์ผ ์˜คํ›„ 12:44 Marcus Hitchins [email protected]
์ผ๋‹ค:

๋‚˜๋Š” ์–ป๋‹ค :

  • [email protected]
    50.957์ดˆ์— 1๊ฐœ ํŒจํ‚ค์ง€ ์—…๋ฐ์ดํŠธ
    (xenial) marcus@localhost :~/app$ firebase serve --only ๊ธฐ๋Šฅ

=== '/home/marcus/app'์—์„œ ๊ฒ€์ƒ‰ ์ค‘...

์˜ค๋ฅ˜: ๋ฐฐํฌํ•  ๋Œ€์ƒ์„ ์ดํ•ดํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. --only ๋˜๋Š” --except ํ”Œ๋ž˜๊ทธ๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒฝ์šฐ ์œ ํšจํ•œ ๋Œ€์ƒ์„ ์ง€์ •ํ–ˆ๋Š”์ง€ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด firebase.json์„ ํ™•์ธํ•˜์—ฌ ํ”„๋กœ์ ํŠธ๊ฐ€ ์›ํ•˜๋Š” ๊ธฐ๋Šฅ์œผ๋กœ ์ดˆ๊ธฐํ™”๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.

โ€”
์ด ์Šค๋ ˆ๋“œ์— ๊ฐ€์ž…ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ›๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ์ด๋ฉ”์ผ์— ์ง์ ‘ ๋‹ต์žฅํ•˜๊ณ  GitHub์—์„œ ํ™•์ธํ•˜์„ธ์š”.
https://github.com/firebase/firebase-tools/issues/609#issuecomment-359200751 ,
๋˜๋Š” ์Šค๋ ˆ๋“œ ์Œ์†Œ๊ฑฐ
https://github.com/notifications/unsubscribe-auth/AAAD_tJH6ez89mjEZVdJbPVMDqeKym76ks5tMlAQgaJpZM4Rj8M0
.

@mono0926 ์šฐ๋ฆฌ๋Š” ์—๋ฎฌ๋ ˆ์ดํ„ฐ ๋‚ด๋ถ€์—์„œ ์‚ฌ์šฉ์ž ์ •์˜ ๊ตฌ์„ฑ ๊ฐ’์„ ์ง€์›ํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๋ณ€์ˆ˜๊ฐ€ .runtimeconfig.json์— ์ €์žฅ๋˜๊ณ  ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ์ˆ˜ ํด๋” ๋‚ด์—์„œ "firebase functions:config:get > .runtimeconfig.json"์„ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์—๋ฎฌ๋ ˆ์ดํ„ฐ.

@marcus7777 https://github.com/firebase/firebase-tools/issues/442 ์—์„œ ์บก์ฒ˜ํ•œ ๋ณ„๋„์˜ ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

์›๋ž˜ ๋ณด๊ณ ๋œ ์˜ค๋ฅ˜๊ฐ€ v.3.17.3์—์„œ ์ˆ˜์ •๋˜์—ˆ์œผ๋ฏ€๋กœ ์ง€๊ธˆ ์ด ๋ฌธ์ œ๋ฅผ ๋‹ซ์Šต๋‹ˆ๋‹ค.

์ด๊ฒƒ์ด ์–ผ๋งˆ๋‚˜ ๋นจ๋ฆฌ ์ฒ˜๋ฆฌ๋˜์—ˆ๋Š”์ง€ ๋†€๋ž์Šต๋‹ˆ๋‹ค. ๋ฉ‹์ง„ ์ž‘ํ’ˆ @laurenzlong. ๐Ÿ‘

@laurenzlong

๋ณ€์ˆ˜๊ฐ€ .runtimeconfig.json์— ์ €์žฅ๋˜๊ณ  ์—๋ฎฌ๋ ˆ์ดํ„ฐ์—์„œ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ์ˆ˜ ํด๋” ๋‚ด์—์„œ "firebase functions:config:get > .runtimeconfig.json"์„ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋‚ด๊ฐ€ ์ฐธ์กฐ. ์ด ์ •๋ณด๋ฅผ ์“ฐ๋Š” ๊ฒƒ์„ ์žŠ์—ˆ์Šต๋‹ˆ๋‹ค.
functions/.runtimeconfig.json ์ž…๋‹ˆ๋‹ค.

{
  "environment": {
    "project_id": "development"
  }
}

v3.16.0 ๋ฏธ๋งŒ์—์„œ๋Š” functions.config().environment. project_id ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์—ˆ์ง€๋งŒ ์ตœ์‹  ๋ฒ„์ „(v3.17.3)์—์„œ๋Š” ์ ‘๊ทผํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

@mono0926 ์ด์— ๋Œ€ํ•œ ์ƒˆ ๋ฌธ์ œ๋ฅผ ์—ด โ€‹โ€‹์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ? ๋˜ํ•œ ์‚ฌ์šฉ ์ค‘์ธ firebase-functions์˜ ๋ฒ„์ „์„ ํฌํ•จ์‹œํ‚ค์‹ญ์‹œ์˜ค.

@laurenzlong

์ด์— ๋Œ€ํ•œ ์ƒˆ ๋ฌธ์ œ๋ฅผ ์—ด โ€‹โ€‹์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ? ๋˜ํ•œ ์‚ฌ์šฉ ์ค‘์ธ firebase-functions์˜ ๋ฒ„์ „์„ ํฌํ•จ์‹œํ‚ค์‹ญ์‹œ์˜ค.

์ž, ๋ฌธ์ œ๋ฅผ ์—ด์—ˆ์Šต๋‹ˆ๋‹ค ๐Ÿ‘ : https://github.com/firebase/firebase-tools/issues/629

3.17.4๋กœ ์—…๋ฐ์ดํŠธํ•˜๋ฉด ์—ฌ์ „ํžˆ ๋‹ค์Œ์„ ์–ป์Šต๋‹ˆ๋‹ค.

sudo npm install -g firebase-tools
[sudo] password for marcus: 
npm WARN deprecated [email protected]: Use uuid module instead
/usr/bin/firebase -> /usr/lib/node_modules/firebase-tools/bin/firebase
+ [email protected]
updated 4 packages in 555.594s
(xenial)marcus<strong i="6">@localhost</strong>:~$ cd app/
(xenial)marcus<strong i="7">@localhost</strong>:~/app$ firebase serve --only functions

=== Serving from '/home/marcus/Downloads/deko-app'...

โš   functions: Cannot start emulator. Error: Cannot find module '/usr/lib/node_modules/firebase-tools/node_modules/grpc/src/node/extension_binary/grpc_node.node'
(xenial)marcus<strong i="8">@localhost</strong>:~/app$

#442๋ฅผ ์‹œ๋„ํ–ˆ์ง€๋งŒ ์šด์ด ์—†์—ˆ์Šต๋‹ˆ๋‹ค.
์ถ”์‹ . xenial(Linux)์—์„œ ์‹คํ–‰

@marcus7777 ๊ท€ํ•˜๊ฐ€ ์ง๋ฉดํ•œ ๋ฌธ์ œ๋Š” ์ด ๋ฌธ์ œ์™€ ๊ด€๋ จ์ด ์—†์Šต๋‹ˆ๋‹ค. firebase-tools๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ๋‹ค์‹œ ์„ค์น˜ํ•ด ๋ณด์‹ญ์‹œ์˜ค. ์ž‘๋™ํ•˜์ง€ ์•Š์œผ๋ฉด ์ƒˆ ๋ฌธ์ œ๋ฅผ ์—ฝ๋‹ˆ๋‹ค.

๋˜ํ•œ ์—๋ฎฌ๋ ˆ์ดํ„ฐ์˜ ๋กœ์ปฌ ์ƒํƒœ๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ์‚ญ์ œํ–ˆ์Šต๋‹ˆ๋‹ค.

$HOME/.config/configstore/@google-cloud/functions-emulator/.functions.json

๋ฐ ์œ ์‚ฌํ•œ ํŒŒ์ผ.
๊ฐ์‚ฌ

์•ˆ๋…•ํ•˜์„ธ์š”,

[email protected]์—์„œ๋„ ์ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

@rafasoares ๊ฐ€ ์–ธ๊ธ‰ํ•œ ๊ฒƒ์ฒ˜๋Ÿผ ๋‹ค์Œ ์ค„์„ ์ถ”๊ฐ€ํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.

admin.initializeApp(functions.config().firebase);

์ด๊ฒƒ์€ ๋‚ด๊ฐ€ ์–ป๋Š” ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.

โžœ  functions yarn run shell
yarn run v1.5.1
$ yarn run build && firebase experimental:functions:shell
$ tsc
i  functions: Preparing to emulate functions.
โš   functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
โš   functions: Error from emulator. Error occurred while parsing your function triggers. Please ensure you have the latest firebase-functions SDK by running "npm i --save firebase-functions@latest" inside your functions folder.

Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.
    at init (/Volumes/HDD/carlosbernal/Dropbox/Wanttu/Futbol/backend/functions/node_modules/firebase-functions/lib/config.js:55:15)
    at Object.config (/Volumes/HDD/carlosbernal/Dropbox/Wanttu/Futbol/backend/functions/node_modules/firebase-functions/lib/config.js:29:9)
    at Object.<anonymous> (/Volumes/HDD/carlosbernal/Dropbox/Wanttu/Futbol/backend/functions/lib/index.js:5:35)
    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)
No functions emulated.
โœจ  Done in 11.64s.

๋˜ํ•œ [email protected] ๋กœ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œํ•˜๋ฉด ์…ธ์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ์ƒˆ ์˜ค๋ฅ˜๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.

โžœ  functions yarn run shell
yarn run v1.5.1
$ yarn run build && firebase experimental:functions:shell
$ tsc
i  functions: Preparing to emulate functions.
โš   functions: Error from emulator. TypeError: Cannot read property 'split' of undefined
โœ”  functions: addMessage
firebase >

@laurenzlong ๋‚ด๊ฐ€ ๋†“์นœ ๊ฒƒ์ด ์žˆ์Šต๋‹ˆ๊นŒ?

@BernalCarlos ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€์—์„œ ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด ์ตœ์‹  firebase-functions ๋ฒ„์ „์ธ์ง€ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค. ํ•จ์ˆ˜ ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜์‹ญ์‹œ์˜ค: `npm i --save firebase -functions@latest '

๊ทธ๋Ÿฐ ๋‹ค์Œ functions/package.json์— firebase-functions 0.8.1์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

@laurenzlong ์ด๋ฏธ ์ตœ์‹  ๋ฒ„์ „์˜ firebase-functions๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ๋‚ด package.json์ž…๋‹ˆ๋‹ค.

{
  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc",
    "serve": "yarn run build && firebase serve --only functions",
    "shell": "yarn run build && firebase experimental:functions:shell",
    "start": "yarn run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^5.9.1",
    "firebase-functions": "^0.8.1"
  },
  "devDependencies": {
    "tslint": "^5.9.1",
    "typescript": "^2.7.2"
  },
  "private": true
}

yarn.lock์—๋Š” ๋‹ค์Œ๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

...

firebase-functions@^0.8.1:
  version "0.8.1"
  resolved "https://registry.yarnpkg.com/firebase-functions/-/firebase-functions-0.8.1.tgz#a42fe6d243862c406af16e1c16b1d0a81ec24c03"
  dependencies:
    "@types/express" "^4.0.33"
    "@types/jsonwebtoken" "^7.1.32"
    "@types/lodash" "^4.14.34"
    "@types/sha1" "^1.1.0"
    express "^4.0.33"
    jsonwebtoken "^7.1.9"
    lodash "^4.6.1"
    sha1 "^1.1.1"

...

firebase-admin@^5.9.1:
  version "5.9.1"
  resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-5.9.1.tgz#1edf6248d014063f0e473f84fe9d63df18e53807"
  dependencies:
    "@firebase/app" "^0.1.10"
    "@firebase/database" "^0.1.11"
    "@google-cloud/firestore" "^0.12.0"
    "@google-cloud/storage" "^1.6.0"
    "@types/google-cloud__storage" "^1.1.7"
    "@types/node" "^8.0.53"
    faye-websocket "0.9.3"
    jsonwebtoken "8.1.0"
    node-forge "0.7.1"

๊ทธ๋Ÿฌ๋‚˜ ๋ฌธ์ œ๋Š” ์—ฌ์ „ํžˆ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

package.json์„ ๊ณต์œ ํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ๊ฐ€ ๋ฌด์—‡์ธ์ง€ ์•Œ๋ ค์ฃผ์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ? ์•„์ง ๋ชจ๋…ธ ์ €์žฅ์†Œ๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ functions/node_modules/firebase-functions ํด๋”๊ฐ€ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋ฌผ๋ก  @laurenzlong ์ด ๋‚ด ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ๋Š” node_modules ํด๋” ๋•Œ๋ฌธ์— ์ƒ๋‹นํžˆ ํฝ๋‹ˆ๋‹ค.

ํด๋” ๊ตฌ์กฐ.txt

[email protected] (์˜ˆ: firebase CLI) ๋ฌธ์ œ๊ฐ€ ๋‹ค์‹œ ๋‚˜ํƒ€๋‚˜๋ฉฐ ๊ธฐ๋Šฅ๊ณผ ์ง์ ‘ ๊ด€๋ จ์ด ์—†์ง€๋งŒ 3.17.4๋กœ ๋กค๋ฐฑํ•˜๋ฉด ์—๋ฎฌ๋ ˆ์ด์…˜์ด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.
firebase-tools repo: firebase/firebase-tools#691์—์„œ ํ•ด๋‹น ๋ฌธ์ œ๋ฅผ ์—ด์—ˆ์Šต๋‹ˆ๋‹ค.

@Rulsky with [email protected] , ๋งค์šฐ ๊ฐ„๋‹จํ•œ ๊ธฐ๋Šฅ์— ๋Œ€ํ•ด ๋‹ค๋ฅธ ์˜ค๋ฅ˜๋กœ ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค.

// index.ts

import * as fbAdmin from "firebase-admin";
import * as fbFunctions from "firebase-functions";

fbAdmin.initializeApp(fbFunctions.config().firebase);

export const addMessage = fbFunctions.https.onRequest((request, response) => {
    const original = request.query.text;
    response.send(original);
});

์˜ค๋ฅ˜:

โžœ  functions yarn run shell
yarn run v1.5.1
$ yarn run build && firebase experimental:functions:shell
$ tsc
i  functions: Preparing to emulate functions.
โš   functions: Failed to emulate addMessage
No functions emulated.
โœจ  Done in 12.71s.

๋˜ํ•œ Firebase CLI๊ฐ€ ์‹คํ–‰๋  ๋•Œ ๋กœ๊ทธ ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜์ง€๋งŒ ํ•ด๋‹น ํŒŒ์ผ์€ ์ฆ‰์‹œ ์‚ญ์ œ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ๋กœ๊ทธ ํŒŒ์ผ์ด ์‚ญ์ œ๋˜์ง€ ์•Š๋„๋ก ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๊นŒ?

@BernalCarlos ํ”„๋กœ์ ํŠธ์˜ functions ๋””๋ ‰ํ† ๋ฆฌ์— ์„œ๋น„์Šค ๊ด€๋ฆฌ์ž ํ‚ค๋ฅผ ๋„ฃ์—ˆ์Šต๋‹ˆ๊นŒ? ๊ทธ๋ฆฌ๊ณ  ์…ธ์—์„œ GOOGLE_APPLICATION_CREDENTIALS ์ „์—ญ ๋ณ€์ˆ˜๋ฅผ ๋‚ด๋ณด๋ƒˆ์Šต๋‹ˆ๊นŒ?
https://firebase.google.com/docs/functions/local-emulator ๊ฐ€ ์ž‘๋™ํ•˜๋„๋ก ํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

Firebase ์ธ์ฆ ๋˜๋Š” ๊ธฐํƒ€ Google API๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์‹ค์ œ๋กœ GOOGLE_APPLICATION_CREDENTIALS๋ฅผ ์„ค์ •ํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ @BernalCarlos ๊ท€ํ•˜์˜ ๋ฌธ์ œ๋Š” https://github.com/firebase/firebase-tools/issues/691 ๊ณผ ๋™์ผํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ์ˆ˜์ •ํ•˜๊ณ  ํ•ด๋‹น ๋ฌธ์ œ์— ์—ฐ๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.

const app = admin.initializeApp(functions.config().firebase); ๋ฅผ ํฌํ•จํ•  ๋•Œ CLI๊ฐ€ ์ƒ์„ฑํ•˜๊ณ  ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๊ธฐ๋Šฅ๋งŒ ์žˆ๋Š” ๊นจ๋—ํ•œ ํ”„๋กœ์ ํŠธ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ์ ํŠธ๋Š” ๋‹ค์Œ์œผ๋กœ ์„ค์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
```
"์ข…์†์„ฑ": {
"firebase-admin": "~5.8.1",
"firebase-functions": "^0.8.1"
}
````

@Jhony0311 ๋‹น์‹ ๋„ #691์˜ ์˜ํ–ฅ์„ ๋ฐ›์•˜์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

firebase deploy --only functions ๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์ง€๋งŒ firebase serve --only functions ๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

"npm run serve"๋ฅผ ์‹คํ–‰ํ•œ ํ›„์—๋„ ๊ณ„์† ๋กœ๋“œ๋ฉ๋‹ˆ๋‹ค.

i ๊ธฐ๋Šฅ: ๊ธฐ๋Šฅ ์—๋ฎฌ๋ ˆ์ด์…˜ ์ค€๋น„.
๊ฒฝ๊ณ : Node.js v10.5.0์„ ์‚ฌ์šฉ ์ค‘์ด์ง€๋งŒ Google Cloud Functions๋Š” v6.11.5๋งŒ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.
โš  ๊ธฐ๋Šฅ: getSomeData ์—๋ฎฌ๋ ˆ์ด์…˜ ์‹คํŒจ
i ๊ธฐ๋Šฅ: HTTPS ๊ธฐ๋Šฅ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์œ ํ˜•์˜ ๊ธฐ๋Šฅ์„ ์—๋ฎฌ๋ ˆ์ดํŠธํ•˜๋ ค๋ฉด Firebase functions:shell ์„ ์‚ฌ์šฉํ•˜์„ธ์š”.

firebase version: 3.19.3

์ด๊ฒƒ์€ ๋‚ด ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

'use strict';

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp();

exports.getSomeData = functions.https.onRequest((req, res) => {
  admin.firestore().doc('feedback/d8pGxmML5ZKLYEy5jyhm').get()
    .then(doc => res.send(doc.data()))
    .catch(err => res.status(500).send(err));
});

์–ด๋–ค ์ œ์•ˆ?

์•ˆ๋…•ํ•˜์„ธ์š”, ๋…ธ๋“œ 10์— ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด์ „ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜์‹ญ์‹œ์˜ค. ์˜ˆ๋ฅผ ๋“ค์–ด ๋ฒ„์ „ 8.
2018๋…„ 7์›” 4์ผ 01:46 +0200, Nicolas Sturm [email protected] ์ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ผ์Šต๋‹ˆ๋‹ค.

firebase deploy --only ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์ง€๋งŒ firebase serve --only ๊ธฐ๋Šฅ์€ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
"npm run serve"๋ฅผ ์‹คํ–‰ํ•œ ํ›„์—๋„ ๊ณ„์† ๋กœ๋“œ๋ฉ๋‹ˆ๋‹ค.
i ๊ธฐ๋Šฅ: ๊ธฐ๋Šฅ ์—๋ฎฌ๋ ˆ์ด์…˜ ์ค€๋น„.
๊ฒฝ๊ณ : Node.js v10.5.0์„ ์‚ฌ์šฉ ์ค‘์ด์ง€๋งŒ Google Cloud Functions๋Š” v6.11.5๋งŒ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.
โš  ๊ธฐ๋Šฅ: getSomeData ์—๋ฎฌ๋ ˆ์ด์…˜ ์‹คํŒจ
i ๊ธฐ๋Šฅ: HTTPS ๊ธฐ๋Šฅ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์œ ํ˜•์˜ ๊ธฐ๋Šฅ์„ ์—๋ฎฌ๋ ˆ์ดํŠธํ•˜๋ ค๋ฉด Firebase functions:shell ์„ ์‚ฌ์šฉํ•˜์„ธ์š”.
Firebase ๋ฒ„์ „: 3.19.3
์ด๊ฒƒ์€ ๋‚ด ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.
'์—„๊ฒฉํ•œ ์‚ฌ์šฉ';

const ํ•จ์ˆ˜ = require('firebase-functions');
const ๊ด€๋ฆฌ์ž = ์š”๊ตฌ('ํŒŒ์ด์–ด๋ฒ ์ด์Šค ๊ด€๋ฆฌ์ž');

admin.initializeApp();

export.getSomeData = functions.https.onRequest((req, res) => {
admin.firestore().doc('ํ”ผ๋“œ๋ฐฑ/d8pGxmML5ZKLYEy5jyhm').get()
.then(doc => res.send(doc.data()))
.catch(err => res.status(500).send(err));
});
์–ด๋–ค ์ œ์•ˆ?
โ€”
๋‹น์‹ ์ด ์–ธ๊ธ‰๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด๊ฒƒ์„ ๋ฐ›๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
์ด ์ด๋ฉ”์ผ์— ์ง์ ‘ ๋‹ต์žฅํ•˜๊ฑฐ๋‚˜ GitHub์—์„œ ๋ณด๊ฑฐ๋‚˜ ์Šค๋ ˆ๋“œ๋ฅผ ์Œ์†Œ๊ฑฐํ•˜์„ธ์š”.

๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์—๊ฒŒ ๋„์›€์ด ๋˜๋Š” ๊ฒฝ์šฐ Dialogflow์˜ fulfillment ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์ฝ”๋“œ๋ฅผ ๋กœ์ปฌ์—์„œ ํŽธ์ง‘ ๋ฐ ํ…Œ์ŠคํŠธํ•˜๋ ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ์„ ํ•ด๊ฒฐ ํ•œ ๊ฒƒ์€ @rafasoares ๊ฐ€ ๋งํ•œ ๊ฒƒ๊ณผ ์œ ์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค.

์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์ƒ์„ฑ๋œ firebase init ๊ฐ€ ์•„๋‹Œ ์‚ฌ์šฉ๋œ package.json Dialogflow ๋ฅผ ๋ณต์‚ฌํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฒ„์ „ ๋ฌธ์ œ์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๋‚˜๋Š” ๋˜‘๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ๋ฐฐํฌ ๋‹จ๊ณ„์—์„œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  JSON ๊ตฌ์„ฑ ํŒŒ์ผ๋งŒ ์‚ฌ์šฉํ•  ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ์ˆ˜์ • ์‚ฌํ•ญ์„ ๋ณด๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค. npm์„ ์‹คํ–‰ํ•ด๋„ ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ œ ๊ฒฝ์šฐ์—๋Š” firebase deploy ๋ฅผ ๋จผ์ € ์‹คํ–‰ํ•œ ๋‹ค์Œ firebase serve ๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ๋ฒ„๊ทธ๋ฅผ ์ˆ˜์ •ํ–ˆ๊ณ  ๋ฒ„๊ทธ๊ฐ€ ์‚ฌ๋ผ์กŒ์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  firebase-tools, firebase-admin, firebase-functions์„ ์ตœ์‹  ๊ฒƒ์œผ๋กœ ์—…๋ฐ์ดํŠธํ–ˆ์Šต๋‹ˆ๋‹ค.

"dependencies": {
    "firebase-admin": "^7.3.0",
    "firebase-functions": "^2.3.0",
    "googleapis": "^32.0.0",
    "mailgun-js": "^0.18.0",
    "moment": "^2.20.1",
    "request": "^2.81.0",
    "request-promise": "^4.2.1"
  },
  "private": true,
  "devDependencies": {
    "firebase-functions-test": "^0.1.2",
    "firebase-tools": "^6.8.0",
    "mocha": "^5.2.0",
    "rewire": "^4.0.1",
    "sinon": "^6.0.0",
    "underscore": "^1.9.1"
  },

๊ทธ๋Ÿฌ๋‚˜ Firebase ๊ธฐ๋Šฅ ์…ธ์„ ์‹คํ–‰ํ•˜๋ ค๊ณ  ํ•  ๋•Œ ์—ฌ์ „ํžˆ ์ด ์˜ค๋ฅ˜๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

i  functions: Preparing to emulate functions.
โš   functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
โš   functions: Error from emulator. Error occurred while parsing your function triggers.

@Randyanto ์•ˆ๋…•ํ•˜์„ธ์š”, ๋ช…ํ™•ํ•œ ๋‹ต๋ณ€์„ ๋“œ๋ฆด ์ˆ˜๋Š” ์—†์ง€๋งŒ ๋ช‡ ๊ฐ€์ง€ ๋‹จ์„œ๋ฅผ ๋“œ๋ฆด ์ˆ˜๋Š” ์žˆ์Šต๋‹ˆ๋‹ค. ๋‚˜๋„ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. ์ œ ๊ฒฝ์šฐ์—๋Š” require('firebase') ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ' [email protected] ' ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œ๋ฅผ ์‹œ๋„ํ–ˆ์Šต๋‹ˆ๋‹ค.
npm install --save [email protected] ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋งˆ์นจ๋‚ด ๋‚˜๋Š” ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.
Firebase ๋˜๋Š” ๊ธฐํƒ€ ๊ธฐ๋Šฅ๊ณผ ๊ด€๋ จ๋œ ๋ฌธ์ œ๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฐ ๋ฒ„์ „ ์ข…์†์„ฑ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค. ํ–‰์šด์„ ๋น•๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰