My JS Code(Firebase):
<script type="module">
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
import { initializeApp } from "firebase/app"
import { getAuth, onAuthStateChanged,createUserWithEmailAndPassword } from "firebase/auth";
import { getDatabase } from "firebase/database"
// Your web app's Firebase configuration
const firebaseConfig = {
//app config
};
// Initialize Firebase
const firebaseApp = initializeApp(firebaseConfig);
const db = getDatabase(firebaseApp);
const auth = getAuth(firebaseApp);
</script>
My Script file for authentication:
import { createUserWithEmailAndPassword } from 'firebase/auth';
console.log("helossssss");
let signupbtn = document.querySelector('.signupbtn');
signupbtn.addEventListener('click', (e) => {
console.log(e);
// e.preventDefault();
let email = document.querySelector('#newuseremail');
let password = document.querySelector('#newuserpassword');
console.log("Heelo World")
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
let user = userCredential.user;
console.log(user);
email.value = "";
password.value = "";
})
.catch((err) => {
console.log(err);
})
})
I am getting this error repeatedly:
Uncaught TypeError: Failed to resolve module specifier "firebase/auth". Relative references must start with either "/", "./", or "../".
I have already referred to the docs for upgradation from compat code to modular code: https://firebase.google.com/docs/web/modular-upgrade#update_imports_to_v9_compat
But that doesn't seem to resolve my problem.