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
Friend just import it like this "import { useAuthState } from 'react-firebase-hooks/auth';"
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.