Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

node.js - Running Cloud Functions locally gives error "functions.config() is not available"

Cloud Functions for Firebase was just recently released and I am following the instructions on a fresh install. Here is the "Get Started" page.

I have installed "npm install -g firebase-tools" and all my files are in my project. I am using WebStorm 2016.3 and Node.JS v6.10.0.

I have the firebase login and firebase init functions installed and set up as well. My set up. Here is my set up.

My package.json

 {
   "name": "functions",
   "description": "Cloud Functions for Firebase",
    "dependencies": {
     "firebase-admin": "^4.1.2",
     "firebase-functions": "^0.5"
   },
    "private": true
 }

These first two lines of code work.

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

But then when I try to run this line...

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

I get this error.

 Error: functions.config() is not available. Please use the latest version of the Firebase CLI to deploy this function.
   at init (/Users/.../functions/node_modules/firebase-functions/lib/config.js:46:19)
   at Object.config (/Users/.../functions/node_modules/firebase-functions/lib/config.js:29:9)
   at Object.<anonymous> (/Users/.../functions/index.js:11: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.runMain (module.js:604:10)
   at run (bootstrap_node.js:394:7)

What am I missing here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...