Alejov
Alejov

Reputation: 529

Firebase CloudScheduler GCLOUD_PROJECT error

This is my function with the configuration at the top, and the function at the bottom

const functions = require('firebase-functions')
const Stripe = require('stripe')

const axios = require('axios')
const admin = require('firebase-admin')
const serviceAccount = require('./serviceAccountKey.json')

admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL: 'https://c6dcc.firebaseio.com'
})

exports.detectConnect = functions.pubsub
 .topic('detectConnect')
 .onPublish(async message => {
    console.log('THIS THING RAN')
    return null
 })

These are my dependencies

"dependencies": {
    "@google-cloud/storage": "^2.0.0",
    "axios": "^0.19.0",
    "child-process-promise": "^2.2.1",
    "firebase-admin": "~7.0.0",
    "firebase-functions": "^2.2.0",
    "mkdirp": "^0.5.1",
    "mkdirp-promise": "^5.0.1",
    "node-fetch": "^2.6.0",
    "request": "^2.88.0",
    "stripe": "^7.1.0"
},

But firebase throws an error

Error: process.env.GCLOUD_PROJECT is not set.
at TopicBuilder (/srv/functions/node_modules/firebase-functions/lib/providers/pubsub.js:43:19)
at cloudFunctionNewSignature (/srv/functions/node_modules/firebase-functions/lib/cloud-functions.js:102:13)
at cloudFunction (/srv/functions/node_modules/firebase-functions/lib/cloud-functions.js:151:20)
at Promise.resolve.then (/srv/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28)
at process._tickCallback (internal/process/next_tick.js:68:7)

The error is also present when using schedule-functions

Upvotes: 1

Views: 2687

Answers (1)

Michael Bleigh
Michael Bleigh

Reputation: 26343

If you're running Node 10, please make sure you're on the latest version of firebase-tools and make sure you're deploying using the Firebase CLI. As of Node 10, the GCLOUD_PROJECT environment variable is no longer available by default.

If you're still running into problems, try changing your Node engine in package.json to "8" and see if you have more success.

Upvotes: 4

Related Questions