Deep Shah
Deep Shah

Reputation: 125

Can't resolve 'react-firebase-hooks'

I am working on Next js project and I installed packeage named react-firebase-hooks. My Package.json file:

{
  "name": "whatsapp",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "@material-ui/core": "^4.11.3",
    "@material-ui/icons": "^4.11.2",
    "axios": "^0.21.1",
    "email-validator": "^2.0.4",
    "firebase": "^8.3.1",
    "next": "10.1.2",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-firebase-hooks": "^3.0.3",
    "styled-components": "^5.2.2"
  }
}

But when I tried to import it in Next js file _app.js like

import '../styles/globals.css'
import {useAuthState} from "react-firebase-hooks"

function MyApp({ Component, pageProps }) {

  return <Component {...pageProps} />
}

export default MyApp

But I am getting error:

error - ./pages/_app.js:2:0
Module not found: Can't resolve 'react-firebase-hooks'
  1 | import '../styles/globals.css'
> 2 | import {useAuthState} from "react-firebase-hooks"
  3 |
  4 | function MyApp({ Component, pageProps }) {

I can't understand why this error is coming coz I have Installed the package but still getting error like this

PS E:\Next\whatsapp> node -v
v14.16.0
PS E:\Next\whatsapp> npm -v
7.6.0

Upvotes: 0

Views: 2108

Answers (3)

I had similar issue too, I had to restart my server and it worked normally after the restart

Upvotes: 0

Yeghishe Karapetyan
Yeghishe Karapetyan

Reputation: 66

Friend just import it like this "import { useAuthState } from 'react-firebase-hooks/auth';"

Upvotes: 5

Filip Huhta
Filip Huhta

Reputation: 2368

Its maybe just something that went wrong with the installation try remove node_modules and install it again.

rm -rf node_modules/
npm install --save react-firebase-hooks

Upvotes: 1

Related Questions