简体   繁体   中英

Firebase Uncaught TypeError: Failed to resolve module specifier "firebase/app". Relative references must start with either "/", "./", or "../"

<script type="module">
  import { initializeApp } from 'firebase/app';
  import { getDatabase } from 'firebase/database';

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

  const app = initializeApp(firebaseConfig);

  const database = getDatabase(app)
</script>

The Uncaught TypeError occurs in line 2. What is the problem?

Usually, this happens because firebase's newest version tools for developers for tools like database , auth , etc, are buggy. Install an older version of firebase. That will surely do the trick. (I am guessing you are using NPM or Yarn to install them, so do something like npm i firebase@5.10.0 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM