React Native не может найти ошибку веб-пакета модуля в приложении. js - Я использую Ubuntu - PullRequest
0 голосов
/ 09 мая 2020

Я впервые использую React Native, и я столкнулся с приведенной ниже ошибкой в ​​моей консоли при попытке запустить приложение в веб-браузере, пожалуйста, кто-нибудь может мне помочь, так как я немного потерялся !! Я использую ubuntu и хочу попробовать протестировать iphone, поскольку я запускаю expo на своем устройстве Samsung

Я загрузил bootstrap, поскольку я думал, что это проблема, но нет, также, если у кого-то есть любые идеи о том, как тестировать реакцию нативных приложений от начала до конца, я попробовал Detox, но потом понял, что это только для Mac !! Заранее благодарим :)

  Uncaught Error: Cannot find module 'nadiaToteWeather/components/Weather.js'
at webpackMissingModule (bootstrap:793)
at Module.../../../../../../../../../../../Desktop/tote/nadiaToteWeather/App.js (bootstrap:793)
at __webpack_require__ (bootstrap:726)
at fn (bootstrap:100)
at Module.../../../../../../../../../../../Desktop/tote/nadiaToteWeather/node_modules/expo/AppEntry.js (AppEntry.js:1)
at __webpack_require__ (bootstrap:726)
at fn (bootstrap:100)
at Object.0 (module.js:22)
at __webpack_require__ (bootstrap:726)
at bootstrap:793
at bootstrap:793
index.js:1 /home/nadia/Desktop/tote/nadiaToteWeather/App.js
Module not found: Can't resolve 'nadiaToteWeather/components/Weather.js' in 
'/home/nadia/Desktop/tote/nadiaToteWeather'

Приложение js

import React from "react";
import { StyleSheet, Text, View } from "react-native";
import Weather from "nadiaToteWeather/components/Weather.js";

export default class App extends React.Component {
state = {
isLoading: false,
};

render() {
const { isLoading } = this.state;

return (
  <View style={styles.container}>
    {isLoading ? <Text>Fetching The Weather</Text> : <Weather />}
  </View>
);
}
 }

 const styles = StyleSheet.create({
  container: {
  flex: 1,
  justifyContent: "center",
 },
 inputContainer: {
  width: "80%",
  borderColor: "black",
  borderWidth: 1,
  padding: 7.5,
  flex: 2,
  },
  });

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": {
"axios": "^0.19.2",
"bootstrap": "^4.4.1",
"detox": "^16.4.1",
"expo": "~37.0.3",
"express": "^4.17.1",
"mocha": "^7.1.2",
"nodemon": "^2.0.3",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-web": "~0.11.7",
"socket.io": "^2.3.0"
},
 "devDependencies": {
"babel-preset-expo": "~8.1.0",
"@babel/core": "^7.8.6"
},
"private": true,
"name": "nadiaToteWeather",
"version": "1.0.0",
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"detox": {
"test-runner": "mocha",
 "configurations": {
    "ios.sim.debug": {
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app",
     "build": "xcodebuild -project ios/example.xcodeproj -scheme example -configuration 
     Debug -sdk iphonesimulator -derivedDataPath ios/build",
    "type": "ios.simulator",
    "device": {
      "type": "iPhone 11 Pro"
     }
    }
    }
   }
   }

1 Ответ

0 голосов
/ 20 мая 2020

Ваш код дублирует каталог nadiaToteWeather в пути к файлу?

имя в bootstrap: индекс 793. js: 1 /home/nadia/Desktop/tote/nadiaToteWeather/App. js Модуль не найден: не удается разрешить 'nadiaToteWeather / components / Weather. js 'in' / home / nadia / Desktop / tote / nadiaToteWeather '

Так что в App. js вы должны использовать:

import Weather из «components / Weather. js»;

Вместо:

импорт погоды из «nadiaToteWeather / components / Weather. js»;

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...