Antosser
Antosser

Reputation: 391

Firebase Functions - Error: There was an error deploying functions

For some reason, I don't know, my cloud function isn't working with the error being:

!  functions: failed to update function projects/jungschar-website/locations/us-central1/functions/createUser
Failed to update function projects/jungschar-website/locations/us-central1/functions/createUser

Functions deploy had errors with the following functions:
        createUser(us-central1)
i  functions: cleaning up build files...

Error: There was an error deploying functions

index.ts

import * as functions from "firebase-functions";
import admin = require("firebase-admin");
admin.initializeApp();

const db = admin.firestore();

export const createUser = functions.auth.user().onCreate((user) => {
  db.doc("users/" + user.uid).set({
    uid: user.uid,
    email: user.email,
    isAdmin: false,
  });
});

firebase-debug.log
https://paste.gg/p/anonymous/827e6ed903df4ad097e6551bd859884f

Please help me. I've been googling for so long

Upvotes: 1

Views: 563

Answers (1)

Antosser
Antosser

Reputation: 391

import * as functions from "firebase-functions";
import admin = require("firebase-admin");
admin.initializeApp();

// const db = admin.firestore();
export const createUser = functions.auth.user().onCreate((user) => {
  admin.firestore().doc("users/" + user.uid).set({
    uid: user.uid,
    email: user.email,
    isAdmin: false,
  });
});

This works

Upvotes: 1

Related Questions