【问题标题】:Can't resolve path of imported file in React Native无法解析 React Native 中导入文件的路径
【发布时间】:2023-04-05 22:51:01
【问题描述】:

我是 React Native 的新手。当我尝试从 React Native 中的另一个文件导入一个类时,我会遇到这样的导入错误。我该如何解决这个问题? (我使用的是 react-navigation 2.18.3)

C:/Users/Suman Shaw/Login/components/Login.js
Module not found: Can't resolve '../config/firebaseSDK' in 'C:\Users\Suman Shaw\Login\components'
[![my folder hierarchy][1]][1]

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~36.0.0",
    "firebase": "^7.9.3",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
    "react-native-gifted-chat": "^0.13.0",
    "react-native-web": "~0.11.7",
    "react-navigation": "^2.18.3",
    "uuid": "^7.0.1"
  },
  "devDependencies": {
    "babel-preset-expo": "~8.0.0",
    "@babel/core": "^7.0.0"
  },
  "private": true
}

【问题讨论】:

    标签: reactjs react-native navigation react-navigation react-navigation-stack


    【解决方案1】:

    Can't resolve '../config/firebaseSDK' 表示你给出了错误的路径

    导入为 '../../' 直到找到 config

    你可以参考这个https://www.youtube.com/watch?v=ephId3mYu9o

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-07
      • 2016-09-02
      • 1970-01-01
      • 2018-07-17
      • 2019-04-09
      • 2017-10-17
      • 2023-01-24
      • 2017-10-10
      相关资源
      最近更新 更多