npm 无法解析“react-firebase-hooks”

wh6knrhe  于 2023-10-19  发布在  React
关注(0)|答案(3)|浏览(133)

我正在下一个js项目工作,我安装了名为react-firebase-hooks的包。我的Package.json文件:

{
  "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"
  }
}

但当我试图将其导入Next js file_app. js时,

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

function MyApp({ Component, pageProps }) {

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

export default MyApp

但我得到了错误:

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 }) {

我不明白为什么这个错误是来的原因我已经安装了软件包,但仍然得到这样的错误

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

dtcbnfnu1#

朋友只需像这样导入它“从'react-firebase-hooks/auth'导入{ useAuthState };“

qij5mzcb

qij5mzcb2#

它可能只是安装出错的东西尝试删除node_modulesinstall它再次。

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

nzk0hqpo3#

我也有类似的问题,我不得不重新启动我的服务器,它正常工作后,重新启动

相关问题