试图建立生产放置时的错误

发布于 2025-02-10 03:23:48 字数 1449 浏览 0 评论 0原文

它给我带来了这个错误:目标环境不支持DynamiC Import()语法,因此在尝试在React for Product中构建应用程序时,无法在脚本中使用外部类型'模块' 。我使用两个文件:app.js和firebase.js。这些是app.js的导入和firebase.js file(其中包含firebase访问配置):

app.js:

import React from 'react';
import {auth, db} from './firebase'

import {
  getFirestore,
  collection,
  getDocs,
  onSnapshot,
  addDoc,
  deleteDoc,
  doc,
  getDoc,
  updateDoc
}from 'https://www.gstatic.com/firebasejs/9.8.1/firebase-firestore.js';

import { getAuth, createUserWithEmailAndPassword, onAuthStateChanged,signInWithEmailAndPassword,signOut} from 'https://www.gstatic.com/firebasejs/9.8.1/firebase-auth.js';

firebase.js:

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.8.1/firebase-app.js";

        import {
          getFirestore,
          collection,
          getDocs,
          onSnapshot,
          addDoc,
          deleteDoc,
          doc,
          getDoc,
          updateDoc,
        } from "https://www.gstatic.com/firebasejs/9.8.1/firebase-firestore.js";

import { getAuth, createUserWithEmailAndPassword, onAuthStateChanged,signInWithEmailAndPassword,signOut} from 'https://www.gstatic.com/firebasejs/9.8.1/firebase-auth.js';     

const firebaseConfig = {
//my data

};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const auth = getAuth(app);
export {auth,db}

it throws me this error: The target environment doesn't support dynamic import() syntax so it's not possible to use external type 'module' within a script, when trying to build an application in react for production. I use two files: App.js and firebase.js. These are the imports of the App.js, and the firebase.js file (which contains the firebase access configuration):

App.js:

import React from 'react';
import {auth, db} from './firebase'

import {
  getFirestore,
  collection,
  getDocs,
  onSnapshot,
  addDoc,
  deleteDoc,
  doc,
  getDoc,
  updateDoc
}from 'https://www.gstatic.com/firebasejs/9.8.1/firebase-firestore.js';

import { getAuth, createUserWithEmailAndPassword, onAuthStateChanged,signInWithEmailAndPassword,signOut} from 'https://www.gstatic.com/firebasejs/9.8.1/firebase-auth.js';

firebase.js:

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.8.1/firebase-app.js";

        import {
          getFirestore,
          collection,
          getDocs,
          onSnapshot,
          addDoc,
          deleteDoc,
          doc,
          getDoc,
          updateDoc,
        } from "https://www.gstatic.com/firebasejs/9.8.1/firebase-firestore.js";

import { getAuth, createUserWithEmailAndPassword, onAuthStateChanged,signInWithEmailAndPassword,signOut} from 'https://www.gstatic.com/firebasejs/9.8.1/firebase-auth.js';     

const firebaseConfig = {
//my data

};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const auth = getAuth(app);
export {auth,db}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文