Help us understand the problem. What is going on with this article?

firebaseui で TypeError: Cannot read property 'auth' of undefined って言われる時

現症

firebaseui を使おうとすると以下のようにエラーになる

Chrome

webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:620 [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'auth' of undefined"

TypeError: Cannot read property 'auth' of undefined

Safari

[Vue warn]: Error in mounted hook: "TypeError: undefined is not an object (evaluating 'new firebaseui__WEBPACK_IMPORTED_MODULE_1__["default"].auth')"

TypeError: undefined is not an object (evaluating 'new firebaseui__WEBPACK_IMPORTED_MODULE_1__["default"].auth')

Firefox

Vue warn]: Error in mounted hook: "TypeError: firebaseui__WEBPACK_IMPORTED_MODULE_1__.default is undefined"

TypeError: "firebaseui__WEBPACK_IMPORTED_MODULE_1__.default is undefined"

対処

firebase と firebaseui の import を以下のように変える

/*
import firebase from "firebase";
import firebaseui from 'firebaseui';
import "firebaseui/dist/firebaseui.css";
*/

import "firebaseui/dist/firebaseui.css";
import * as firebase from "firebase/app";
import "firebase/auth";
import * as firebaseui from 'firebaseui';

references

https://stackoverflow.com/questions/56659510/firebase-auth-typeerror-module-is-undefined/56791881#56791881

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした