module appregistry is not a registered callable module (calling runApplication) 模块appregistry不是一个已注册的可调用模块(调用runApplication)。

14 浏览
0 Comments

module appregistry is not a registered callable module (calling runApplication) 模块appregistry不是一个已注册的可调用模块(调用runApplication)。

我完全找不到让react-navigation工作的方法。我从互联网上复制了一些可行的示例,但它们似乎也无法运行。有人可以告诉我我做错了什么吗?\n我使用的版本是:\n node: 8.9.4\n react: 16.3.0-alpha.1\n react-native: 0.54.0\n react-navigation: ^1.4.0\n这是index.js的代码:\n

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import {
  TabNavigator,
  StackNavigator
} from 'react-navigation';
import Home from './first';
import Homes from './second';
export default class demoApp extends Component {
  render() {
    return (
      
    );
  }
}
export const SimpleNavigation = StackNavigator({
  Home: { 
    screen: Home,
    header: { visible: false },
    navigationOptions: {
      title: 'Home',
      header: null
    },
  },
  Homes: { 
    screen: Homes,
    navigationOptions: {
      title: 'second'
    },
  },
},{});

\n这是first.js的代码:\n

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image,
  TextInput,
  Button,
  TouchableHighlight
} from 'react-native';
export default class Home extends Component {
    constructor(props){
        super(props);
        this.state = {zipCode: ''}
    }
    navigate = (zipCode) => {
        this.props.navigation.navigate('Search', zipCode);
    }
    render() {
        return (
            
                
                    An application to do things
                     this.setState({zipCode})}
                        >
                    
                
                
                     this.navigate(this.state.zipCode)}>
                        
                            Search
                        
                    
                
            
        );
    }
}

\n我似乎无法使其运行。我也尝试了很多其他教程,但都没有成功。我做错了什么?

0
0 Comments

(module appregistry is not a registered callable module (calling runApplication))这个问题的出现的原因是在运行React Native应用程序时,AppRegistry模块没有正确注册。这可能是由于以下原因之一:

1. 缺少必要的配置文件或依赖项。

2. 项目结构或文件路径错误。

3. 缓存问题或代码冲突。

为了解决这个问题,可以尝试以下方法:

1. 杀死所有的Node进程并重新启动npm服务器和运行应用程序:

- 步骤1:运行命令killall -9 node来杀死所有Node进程。

- 步骤2:运行命令npm start来启动npm服务器。

- 步骤3:运行命令react-native run-iosreact-native run-android来运行应用程序。

通过执行上述步骤,可以清除任何可能导致AppRegistry模块未正确注册的问题,并重新启动应用程序。这将提供一个干净的环境,以确保AppRegistry正确运行并注册。

0
0 Comments

关闭您的Nodejs终端并重新运行

0
0 Comments

今天我也一直遇到这个错误,非常烦人。通过移除带有“Metro”绑定程序的终端窗口,然后重新编译应用程序,我成功地摆脱了这个错误。

似乎不是代码的问题,而是运行环境的问题(似乎每次只能正常运行一个应用示例)。您可以通过创建一个非常简单的应用程序来验证这一点,看看是否可以正常工作。

我还不得不点击Android虚拟设备管理器中设备的下拉菜单,选择Wipe Data并重新启动它。

0