0

This is my index.js file:

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

admin.initializeApp();

exports.createUser = functions.auth.user().onCreate((user) => {
    console.log('user')
})

Whenever, I try to run it in a firebase emulator or deploy it, I get this error message:

TypeError: Cannot read properties of undefined (reading 'user')
    at Object.<anonymous> (C:\Users\cwrig\Desktop\gen_mc_skins\front-end-mc-skins\functions\index.js:7:37)
    at Module._compile (node:internal/modules/cjs/loader:1554:14)
    at Object..js (node:internal/modules/cjs/loader:1706:10)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
    at Module.require (node:internal/modules/cjs/loader:1311:12)
    at require (node:internal/modules/helpers:136:16)
    at loadModule (C:\Users\cwrig\Desktop\gen_mc_skins\front-end-mc-skins\functions\node_modules\firebase-functions\lib\runtime\loader.js:40:16)

Furthermore, when I am trying to develop the function and i type functions. I do not see auth popup in ide to autofill.

I have been researching for a few hours, and cannot see what I am missing. I made sure I am on node version 22. I am on firebase tools version: 13.35.1

I have deleted and recreated the firebase functions directory.

I am sure it might just be something small, but nothing I do is fixing it, and documentation seems a little bit out of date to me

1
  • Firebase Auth functions are only available with gen 1 type functions. With modern versions of firebase-functions, you must import functions specifically from the v1 APIs using const functions = require('firebase-functions/v1'); instead of what you have now. Commented Mar 28 at 15:45

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.