React Native - 错误:undefined不是一个对象(正在评估'require('NativeModules')。UIManager.AndroidDrawerLayout.Constants')

问题描述:

根据官方启动指南here,我正在关注React Native的Hello World示例。当在XCode上运行实际的项目(未修改过,没有编辑过文件)时,在“红色死亡屏幕”上出现以下错误。React Native - 错误:undefined不是一个对象(正在评估'require('NativeModules')。UIManager.AndroidDrawerLayout.Constants')

Error: undefined is not an object (evaluating 'require('NativeModules').UIManager.AndroidDrawerLayout.Constants')

的代码股票标准的默认代码什么也没有触及。

任何想法?

谢谢!

Red Screen of Death

/** 
* Sample React Native App 
* https://github.com/facebook/react-native 
*/ 
'use strict'; 

var React = require('react-native'); 
var { 
    AppRegistry, 
    StyleSheet, 
    Text, 
    View, 
} = React; 

var HelloWorld = React.createClass({ 
    render: function() { 
    return (
     <View style={styles.container}> 
     <Text style={styles.welcome}> 
      Welcome to React Native! 
     </Text> 
     <Text style={styles.instructions}> 
      To get started, edit index.ios.js 
     </Text> 
     <Text style={styles.instructions}> 
      Press Cmd+R to reload,{'\n'} 
      Cmd+D or shake for dev menu 
     </Text> 
     </View> 
    ); 
    } 
}); 

var styles = StyleSheet.create({ 
    container: { 
    flex: 1, 
    justifyContent: 'center', 
    alignItems: 'center', 
    backgroundColor: '#F5FCFF', 
    }, 
    welcome: { 
    fontSize: 20, 
    textAlign: 'center', 
    margin: 10, 
    }, 
    instructions: { 
    textAlign: 'center', 
    color: '#333333', 
    marginBottom: 5, 
    }, 
}); 

AppRegistry.registerComponent('HelloWorld',() => HelloWorld); 

尝试在你的应用程序文件夹中运行此命令,然后重新运行该项目:

npm install [email protected] --save 
+0

为我工作!谢谢!! – csm232s

+0

不幸的是,它仍然发生。 React native现在在package.json上设置为'“react-native”:“^ 0.11.2”'。我清理了构建并重新编译了所有内容,并且发生了同样的错误。 –

尝试以下操作:

https://github.com/facebook/react-native/issues/8436

import React, { Component } from 'react'; 
import { 
    AppRegistry, 
    StyleSheet, 
    Text, 
    NavigatorIOS, 
    View 
} from 'react-native'; 

class HelloWorld extends Component {