试图建立生产放置时的错误
它给我带来了这个错误:目标环境不支持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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论