Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
auth.createUserWithEmailAndPassword is not a function

I have the following setup to connect to firebase but for some reason in the browser console it shows that auth.createUserWithEmailAndPassword() is not a function. Is there something wrong with my code?

        import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js';
        import { getAuth, createUserWithEmailAndPassword } from 'https://www.gstatic.com/firebasejs/9.0.2/firebase-auth.js';
        import { getFirestore } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-firestore.js"

        // TODO: Replace the following with your app's Firebase project configuration
        const firebaseConfig = {
            " my config here "
        };

        const app = initializeApp(firebaseConfig);
        const auth = getAuth();
        const db = getFirestore();

        var button = document.getElementById("button").addEventListener("click", function () {
            var email = document.getElementById("email").value;
            var phone = document.getElementById("phone").value;
            var password = document.getElementById("password").value;

            auth.createUserWithEmailAndPassword(email, password).then(cred => {
                console.log(cred);
            })
        });

edit: I removed auth. from auth.createUserWithEmailAndPassword(email, password).then(cred => { console.log(cred); and now it is giving me the current error: ```Uncaught (in promise) TypeError: Cannot create property '_canInitEmulator' on string 'heheboi@gmail.com'

at _performFetchWithErrorHandling (firebase-auth.js:1983)
at _performApiRequest (firebase-auth.js:1958)
at _performSignInRequest (firebase-auth.js:2030)
at signUp (firebase-auth.js:5330)
at createUserWithEmailAndPassword (firebase-auth.js:5978)
at HTMLButtonElement.<anonymous> (register.html:48) ``
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Just update your code to the latest Firebase SDK 9:

import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js';
import { getAuth, createUserWithEmailAndPassword } from 'https://www.gstatic.com/firebasejs/9.0.2/firebase-auth.js';
import { getFirestore } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-firestore.js"

// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
    " my config here "
};

const app = initializeApp(firebaseConfig);
const auth = getAuth();
const db = getFirestore();

var button = document.getElementById("button").addEventListener("click", function () {
    var email = document.getElementById("email").value;
    var phone = document.getElementById("phone").value;
    var password = document.getElementById("password").value;

    createUserWithEmailAndPassword(auth, email, password).then(cred => {
        console.log(cred);
    }).catch((error) => {
      const errorCode = error.code;
      const errorMessage = error.message;
      // ..
    });
});

You are already importing createUserWithEmailAndPassword. You can't use auth.createUserWithEmailAndPassword anymore. You can find here the latest docs.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda