简体   繁体   English

./node_modules/firebase/index.js 错误:ENOENT:没有这样的文件或目录

[英]./node_modules/firebase/index.js Error: ENOENT: no such file or directory

I have got an error with the firebase module for some reason it's no picking it up.由于某种原因,我的 firebase 模块出现错误,无法接收。 This is my file structure on VS code:这是我在 VS 代码上的文件结构:

在此处输入图片说明

These are the 2 files where I need to import auth from firebase:这些是我需要从 firebase 导入身份验证的 2 个文件:

Login.js登录.js

import React, {useState} from 'react';
import "./Login.css";
import {Link, useHistory} from "react-router-dom";
import { auth } from "../firebase"

function Login() {
    const history = useHistory()

    const [email,setEmail] = useState("");
    const [password,setPassword] = useState("")

    const login = (e) => {
        e.preventDefault();
        auth
        .signInWithEmailAndPassword(email,password)
        .then((auth) =>{
            history.push('/');
        })
        .catch(e=>alert(e.message))
    }
    const register = (e) => {
        e.preventDefault();
        auth
        .createUserInWithEmailAndPassword(email,password)
        .then((auth) => {
            history.push('/');
        })
        .catch(e=>alert(e.message))
        
    }
    return (
        <div className="login">
            <Link to="/">
                <img className="login__logo"
                src="http://pngimg.com/uploads/amazon/amazon_PNG24.png"
                alt=""
                />
            </Link>

            <div className = "login__container">
                <h1>Sign in </h1>
                <form>
                <h5>Email</h5>
                <input value={email} onChange = {event => setEmail(event.target.value)} type="email"/>
                <h5>Password</h5>
                <input value={password} onChange = {event => setPassword(event.target.value)}  type="password"/>
                <button onClick = {login} type="submit" className = "login__signInButton"> Sign in</button>
                </form>        

                <p>                         
                    By signing-in you agree to Amazon's Conditions of Use & Sale. Please see our Privacy Notice, our Cookies Notice and our Interest-Based Ads Notice
                </p>
                <button onClick = {register} className="login__registerButton">Create your Amazon Account</button>    
            </div>
        </div>
    )
}

export default Login

App.js应用程序.js

import React, {useEffect} from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import "./App.css";
import Header from "./components/Header";
import Home from "./components/Home";
import Checkout from "./components/Checkout";
import Login from "./components/Login";
import { useStateValue } from "./StateProvider";
import { auth } from "./firebase";

function App() {
  const [{user},dispatch] = useStateValue();
  useEffect(() =>{
    const unsubscribe = auth.onAuthStateChanged((authUser) =>{
      if(authUser){
        dispatch({
          type:"SET_USER",
          user: authUser
        })

      }else{
        dispatch({
          type:"SET_USER",
          user: null
        })
      }
  
  });
  return () => {
    unsubscribe();
  }
  
  },[])

  console.log("USER is >>>", user);

  return (
    <Router>
      <Switch>
        <Route path="/checkout">
          <Header />
          <Checkout />
        </Route>
        <Route path="/login">
          <Login/>
        </Route>
        <Route path="/">
          <Header />
          <Home />
        </Route>
      </Switch>
    </Router>
  );
}

export default App;

I have tried different things but still picking up the wrong file and giving me an error.我尝试了不同的东西,但仍然选择错误的文件并给我一个错误。 Tried npm i and npm i firebase nothign worked.试过 npm i 和 npm i firebase 都没有用。

Thanks谢谢

Not sure if this would help, but exact thing happened to me when I upgraded firebase to version 7.24.0.不确定这是否会有所帮助,但是当我将 firebase 升级到 7.24.0 版时发生了确切的事情。

I changed version back to 7.16.0 and it works now.我将版本改回 7.16.0,现在可以使用了。

暂无
暂无

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

相关问题 错误 in./src/index.js 模块构建失败(来自./node_modules/babel-loader/lib/index.js): - ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Nuxt.js:模块错误(来自./node_modules/eslint-loader/index.js): - Nuxt.js: Module Error (from ./node_modules/eslint-loader/index.js): 从 node_modules index.js 导入 class 定义 - import class definitions from node_modules index.js 未捕获的错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js) - Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js) 魔术 header 未检测到文件已使用这些加载程序处理:*./node_modules/wasm-loader/index.js - magic header not detected File was processed with these loaders: * ./node_modules/wasm-loader/index.js 错误:模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):语法错误: - Error: Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: 错误./node_modules/ts-invariant/process/index.js 24:33-40 - ERROR ./node_modules/ts-invariant/process/index.js 24:33-40 汇总错误:node_modules/react/index.js 未导出“默认” - Rollup Error: 'default' is not exported by node_modules/react/index.js 反应/节点构建错误。 找不到模块“历史”的声明文件。 &#39;node_modules/history/index.js&#39; 隐含一个 &#39;any&#39; 类型 - React/node build error. Could not find a declaration file for module 'history'. 'node_modules/history/index.js' implicitly has an 'any' type ./src/main.ts - 错误:模块构建失败(来自./node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack/src/ivy/index.js): - ./src/main.ts - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack/src/ivy/index.js):
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM