繁体   English   中英

未找到模块:无法解析“C:\Users\Mohammad\Desktop\Chat-System\src\components”中的“..src/firebase.js”

[英]Module not found: Can't resolve '..src/firebase.js' in 'C:\Users\Mohammad\Desktop\Chat-System\src\components'

**I am new to firebase and reactJS and am following a tutorial online and I cant seem to figure out what the problem is. I am getting these errors:**

未找到模块:无法解析“C:\Users\Mohammad\Desktop\Chat-System\src\components”中的“..src/firebase.js”

这是我的 firebase.js 文件:

import firebase from "firebase/compat/app"
    import "firebase/compat/auth"
    import "firebase/compat/firestore"
    import {initializeApp} from "firebase/firebase-app";
    
    var firebaseConfig = {
      apiKey: "AIzaSyBAnPelYqTf2K4WlNjfU7_92u9LS-KFJjQ",
      authDomain: "chit-chat-8d3a1.firebaseapp.com",
      projectId: "chit-chat-8d3a1",
      storageBucket: "chit-chat-8d3a1.appspot.com",
      messagingSenderId: "530247128399",
      appId: "1:530247128399:web:17bfb27e879f37ad1b213a",
      measurementId: "G-0X7Q8F4WFX"
    };
    
    const firebaseApp = initializeApp(firebaseConfig);
    const db = firebaseApp.firestore();
    const auth = firebase.auth();
    const provider = new firebase.auth.GoogleAuthProvider();
    
    export default db;
    export { auth, provider };

这是我的 Login.JS 文件:

//importing React
import React from 'react';
//Importing Icons for Login Page 
import { FacebookOutlined, GoogleOutlined } from '@ant-design/icons';
import firebase from "firebase/compat/app";

import { auth } from '..src/firebase.js';

const Login = () => {

    return (
        <div id="login-page">
            <div id="login-card">
                <h2>Welcome to <a href="https://github.com/pkashi1/Chat-System" title='GitHub Link'>Chit-Chat!</a></h2>
                <p>A Simple, Secure, and User-Friendly Messenger</p>
                <div className="login-button google"
                    onClick={() => auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider())}
                    >
                    <GoogleOutlined/>Sign In With Google
                </div>
                <br></br>
                <br></br>
                <div className="login-button facebook"
                    onClick={() => auth.signInWithRedirect(new firebase.auth.FacebookAuthProvider())}>
                    <FacebookOutlined/>Sign In With Facebook
                </div>
            </div>
        </div>
    );
}

export default Login;

这是我的 package.json 文件,以防出现一些版本错误:

{
  "name": "chitchat-template",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@ant-design/icons": "^4.6.2",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "axios": "^0.21.1",
    "firebase": "^7.20.0",
    "react": "^16.13.1",
    "react-chat-engine": "^1.8.10",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.3",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

由于我是新手,请尽可能多地回复信息,我对很多代码感到困惑,谢谢

根据您所说的判断,我认为问题出在不正确的文件路径上。

您可以尝试代替..src并将其更改为../src/

目前您的项目正在寻找一个名为..src 的文件夹,该文件夹当然不存在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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