简体   繁体   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:**

Module not found: Can't resolve '..src/firebase.js' in 'C:\Users\Mohammad\Desktop\Chat-System\src\components'未找到模块:无法解析“C:\Users\Mohammad\Desktop\Chat-System\src\components”中的“..src/firebase.js”

This is my firebase.js file:这是我的 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 };

This is my Login.JS File:这是我的 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;

Heres my package.json file incase there are some version errors:这是我的 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"
    ]
  }
}

Since I am new to this, please reply with as much information that you can, I am confused by a lot of this code, Thanks由于我是新手,请尽可能多地回复信息,我对很多代码感到困惑,谢谢

Judging off what you have said I believe the issue to be a incorrect file path.根据您所说的判断,我认为问题出在不正确的文件路径上。

Can you try instead of ..src and change it to be ../src/ .您可以尝试代替..src并将其更改为../src/

Currently your project is looking for a folder called..src which of course doesn't exist.目前您的项目正在寻找一个名为..src 的文件夹,该文件夹当然不存在。

暂无
暂无

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

相关问题 放大 React 构建失败,显示“未找到模块:错误:无法解析‘/codebuild/output/src313005886/src/client-portal/src’中的‘./components/...’” - Amplify React build fail with "Module not found: Error: Can't resolve './components/...' in '/codebuild/output/src313005886/src/client-portal/src' " ./src/index.js 未找到模块:无法解析“aws-amplify”React - ./src/index.js Module not found: Can't resolve 'aws-amplify' React 找不到模块:错误:无法在 Kotlin/JS 中解析“firebase/app” - Module not found: Error: Can't resolve 'firebase/app' in Kotlin/JS 找不到模块:无法解析“firebase” - Module not found: Can't resolve 'firebase' in 未找到模块:错误:无法解析“./Firebase” - Module not found: Error: Can't resolve './Firebase' React Native 无法从“firebase.js”解析“firebase” - React Native Unable to resolve "firebase" from "firebase.js" Heroku 未找到模块:错误:无法解析“-/firebase-config” - Heroku Module not found: Error: Can't resolve '-/firebase-config' 错误 in./src/firebase.config.js 6:0-53 未找到模块:错误:Package 路径。/getFirestore 未从 package 导出 - ERROR in ./src/firebase.config.js 6:0-53 Module not found: Error: Package path ./getFirestore is not exported from package Next.js 未找到中间件模块:无法解析“fs” - Next.js middleware Module not found: Can't resolve 'fs' 找不到模块:导入 firebase-admin 时无法解析“http2” - Module Not Found: Can't resolve 'http2' when importing firebase-admin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM