React native:无法解析模块确实,这些文件都不存在: [英] React native :Unable to resolve module Indeed, none of these files exist:

查看:124
本文介绍了React native:无法解析模块确实,这些文件都不存在:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注



这是我的<$ c $代码c> HomeScreen.js

  import React,{Component} from'react'; 
从 react-native导入{Text,View,TextInput,StyleSheet};
从 ./customComponents/floating_title_text_input_field导入FloatingTitleTextInputField;



导出默认类HomeScreen扩展了组件{
render(){
return(
//< View style = {{ flex:1,justifyContent:'center',alignItems:'center'}}>
//< Text>我的第一个React App< / Text>
//< TextInput style = {{高度:40,borderColor:灰色,borderWidth:1}} />
//< / View>

< View style = {styles.container}>
<查看样式= {styles.container}>
<文本样式= {styles.headerText}>它的惊人效果< / Text>
< FloatingTitleTextInputField
attrName = firstName
title =名字
value = {this.state.firstName}
updateMasterState = {this._updateMasterState}
/>
< FloatingTitleTextInputField
attrName = lastName
title =姓氏
value = {this.state.lastName}
updateMasterState = {this._updateMasterState}
/>
< / View>
< / View>
);
}
}
var styles = StyleSheet.create({
container:{
flex:1,
paddingTop:65,
backgroundColor :'white',
},
labelInput:{
color:'#673AB7',
},
formInput:{
borderBottomWidth:1.5,
marginLeft:20,
borderColor:'#333',
},
输入:{
borderWidth:0,
},
});

当我尝试在 FloatingTitleTextInputField 中使用 HomeScreen.js 我遇到以下错误

 错误无法解析模块来自`React Native / AwesomeProject / screens / 

HomeScreen.js`的`。/ floating_title_text_input_field`:在`/ React Native / AwesomeProject / screens / HomeScreen中找不到模块`。/ floating_title_text_input_field`。 js`。实际上,这些文件都不存在:


*`/ React Native / AwesomeProject / screens / floating_title_text_input_field(.native || .android.js | .native.js | .js |。 android.json | .native.json | .json | .android.ts | .native.ts | .ts | .android.tsx | .native.tsx | .tsx)`


*`/ React Native / AwesomeProject / screens / floating_title_text_input_field / index(.native || .android.js | .native.js | .js | .android.json | .native.json | .json | .android.ts | .native.ts | .ts | .android.tsx | .native.tsx | .tsx)`。使用--verbose标志运行CLI以获取更多详细信息。


错误:无法从 React Native / AwesomeProject / screens / HomeScreen.js解析模块 ./floating_title_text_input_field:在模块中找不到模块 ./floating_title_text_input_field / React Native / AwesomeProject / screens / HomeScreen.js`。实际上,这些文件都不存在:

有人可以帮助我解决这个问题吗?



如果需要更多信息,请告诉我。提前致谢。您的努力将受到赞赏。

解决方案

您是从 HomeScreen 组件位于屏幕目录中。因为您使用的是本地./路径,所以它试图在 screens / customComponents 中找到它。使用 ../ customComponents / floating_title_text_input_field 应该可以解决此问题。


I'm following this medium article to use FloatingTitleTextInputField in my react-native project

below is my project structure

Here is my code for HomeScreen.js

import React, {Component} from 'react';
import {Text, View, TextInput, StyleSheet} from 'react-native';
import FloatingTitleTextInputField from './customComponents/floating_title_text_input_field';



export default class HomeScreen extends Component {
  render() {
    return (
      // <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      //   <Text>My First React App</Text>
      //   <TextInput style={{height: 40, borderColor: 'gray', borderWidth: 1}} />
      // </View>

      <View style={styles.container}>
        <View style={styles.container}>
          <Text style={styles.headerText}>Its Amazing</Text>
          <FloatingTitleTextInputField
            attrName="firstName"
            title="First Name"
            value={this.state.firstName}
            updateMasterState={this._updateMasterState}
          />
          <FloatingTitleTextInputField
            attrName="lastName"
            title="Last Name"
            value={this.state.lastName}
            updateMasterState={this._updateMasterState}
          />
        </View>
      </View>
    );
  }
}
var styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: 65,
    backgroundColor: 'white',
  },
  labelInput: {
    color: '#673AB7',
  },
  formInput: {
    borderBottomWidth: 1.5,
    marginLeft: 20,
    borderColor: '#333',
  },
  input: {
    borderWidth: 0,
  },
});

When i try to use FloatingTitleTextInputField inside HomeScreen.js I'm getting below error

    error Unable to resolve module `./floating_title_text_input_field` from `React Native/AwesomeProject/screens/

HomeScreen.js`: The module `./floating_title_text_input_field` could not be found from `/React Native/AwesomeProject/screens/HomeScreen.js`. Indeed, none of these files exist:


  * `/React Native/AwesomeProject/screens/floating_title_text_input_field(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`


  * `/React Native/AwesomeProject/screens/floating_title_text_input_field/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`. Run CLI with --verbose flag for more details.


Error: Unable to resolve module `./floating_title_text_input_field` from `React Native/AwesomeProject/screens/HomeScreen.js`: The module `./floating_title_text_input_field` could not be found from `/React Native/AwesomeProject/screens/HomeScreen.js`. Indeed, none of these files exist:

Can anybody help me to solve this issue

If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.

解决方案

You're referencing it from the HomeScreen component which is in the screens directory. Because you're using the local ./ path, it's trying to find it in screens/customComponents. Using ../customComponents/floating_title_text_input_field should fix it.

这篇关于React native:无法解析模块确实,这些文件都不存在:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆