0

I wanna resolve this question that froze my development.

When i was deploying some Cloud Functions with node 12 to my Firebase project the firebase-cli outputted this:

HTTP Error: 400, Billing account for project 'PROJECT_ID' is not found. Billing must be enabled for activation of service(s) 'cloudbuild.googleapis.com,containerregistry.googleapis.com' to proceed.

So i asked to google like any developer would do and found this question Stack Overflow question.

I changed the package.json in functions directory to:

"engines": {
    "node": "8"
}

It worked! But know i'm testing cloud firestore triggers to listen documents with wild card. Here is the code:

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

admin.initializeApp();

// Getting instance of firestore
const db = admin.firestore();

//Test function
exports.writeToFirestore = functions.firestore
    .document('users/{userId}')
    .onWrite((change, context) => {
        const uid = context.params.userId;
        const newDoc = change.after.data();

        // Reference to userCards inside lawyer doc
        const userCardsDoc = db.doc(`lawyers/lawyer/userCards/userCards`);

        const newCard = {
            uid: uid,
            displayName: newDoc.displayName,
            whatsApp: newDoc.whatsApp,
            picturePath: newDoc.picturePath
        };

        userCardsDoc.set({
            cardsArray: [newCard]
        });
    });

When i change the data of any user doc it triggers the function, but the logs show up this: logs image

Someone knows if that type of function trigger doesn't work at all with node 8 and i should enable billing account in this project to deploy with node 10 or latest or the problem is in my code.

I tried to use this function without wild card but still doesn't work!

  • The billing account error would appear to have nothing to with which node version the code uses. How about just changing the node level to 10 in the package.json file? – danh Oct 28 '20 at 20:02
  • Hey Danh! The "logs image" link in my question show the Logs of function execution, and there is an error: "Node.js v10.0.0 is a minimum requirement. ....". I think that the function isn't working because this error. – Paulo Guedes Oct 28 '20 at 20:19
  • Did you try node 10? – danh Oct 28 '20 at 23:37
  • Yeah. But i can't deploy function without enabling billing, it shows the same error of node 12 – Paulo Guedes Oct 29 '20 at 00:31
  • Credits to @DougStevenson [answer](https://stackoverflow.com/a/62824105/14356364), you should use Nodejs 10 and above then enable your billing account because Cloud Functions for Firebase will rely on some additional paid Google services: Cloud Build, Container Registry, and Cloud Storage. Note that Nodejs 8 might not work since it was deprecated. – JM Gelilio Oct 29 '20 at 03:09

1 Answers1

0

To have an answer to this question, you are receiving an error : Node.js v10.0.0 is a minimum requirement because you are using Node.js v8. The Node.js v8 was deprecated on December 31, 2019 and the minimum requirement now is Node.js v10.

Now, if you are now using Node.js version v10 and above, you can't deploy it if your billing account is disabled or not enabled, why you should enable your billing account?

Because of updates to its underlying architecture planned for August 17, 2020, Cloud Functions for Firebase will rely on some additional paid Google services: Cloud Build, Container Registry, and Cloud Storage. These architecture updates will apply for functions deployed to the Node.js 10 runtime.

JM Gelilio
  • 3,482
  • 1
  • 11
  • 23