这是我第一次使用React Native,尝试在Web浏览器中运行该应用程序时,我在控制台中遇到以下错误,由于我有些失落,请有人可以帮助我!!我正在使用ubuntu,并想在三星设备上运行EXPO时尝试在iPhone上进行测试
我已经下载了引导程序,因为我认为这是问题所在,但不,如果有人对如何测试本机应用程序端到端有任何想法,我也尝试过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'
App.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"
}
}
}
}
}
您的代码是否在文件路径中复制了目录nadiaToteWeather?
引导程序名称:793 index.js:1/home/nadia/Desktop/tote/nadiaToteWeather/App.js找不到模块:无法解析“ nadiaToteWeather / components / Weather.js”'/ home / nadia / Desktop / tote / nadiaToteWeather'
因此,在App.js中,您应该使用:
从“ components / Weather.js”导入天气;
而不是:
从“ nadiaToteWeather / components / Weather.js”导入天气;