【问题标题】:Requiring unknown module "111"需要未知模块“111”
【发布时间】:2020-04-02 12:41:42
【问题描述】:

我想从 localhost:4547 检索数据

所以,我有一个名为 loadText 的函数,假设在这段代码中这样做:

import React, { useState } from 'react'
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native'
import { TextInput } from 'react-native-gesture-handler'
import { response } from 'express'

export default function Home(props) {


  const { navigation } = props

  return (
    <View>
      <Text>Login Screen</Text>
      <Text>{loadText}</Text>
    </View>
  )

  
  function loadText(){
    fetch('http://192.168.1.14:4547/')
      .then((response) => response.json())
      .then((responseJson) => {
        return (
          alert(JSON.stringfy(responseJson))
        );
      })
      .catch((error) => {
        alert(JSON.stringfy(error));
      });
  }

}

问题: 我的 iphone 收到以下错误:。知道什么是“111”模块吗?

附加信息:这是我安装的所有软件包:

【问题讨论】:

  • 你能尝试通过你的项目搜索111吗?看起来你的 package.json 中有 111
  • @OleksandrPaiziak 我的 package.json 中没有 111 的任何内容。我编辑了我的问题,因此如果需要,您可以查看我的 package.json
  • 正如答案所暗示的,只需关闭捆绑器并重新启动它
  • alert(JSON.stringfy 那是不行的

标签: javascript reactjs react-native npm expo


【解决方案1】:

尝试关闭 Metro 错误,如错误所示(具有绿色加载条的终端或 cmd,请按 cntrl + shift + c

然后,在您的项目文件夹中使用npm start --reset-cache 重试。如果这不起作用,请尝试使用 sudo,如果您使用的是 linux。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多