"TypeError: undefined is not an object (evaluating '_react.PropTypes.array')" 在 Mac 上原生 React

时间:2021-05-27 13:16:21

标签: android ios macos react-native

我在 React Native 中遇到了一个问题。我的 React 原生项目完全在 windows 环境下工作。然后我在 Mac 系统中克隆了同一个项目并尝试运行这个项目,它抛出了一个错误。“TypeError: undefined is not an object (evaluating '_react.PropTypes.array')”.我的项目没有显示 PropTypes 的任何结果。我已经重启服务器很多次了。我尝试了不同的解决方案,但没有任何效果。请帮我解决这个问题

这是我的节点日志

 ERROR  TypeError: undefined is not an object (evaluating '_react.PropTypes.array')
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.  
 This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.   
 This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。花了很多时间来确定问题。在我的项目 "react-native-snap-carousel" 库中抛出此错误,在检测到问题后,我遵循了 this link:

npm install prop-types --save // install this
import PropTypes from 'prop-types'; // add import in snap carousel file & remove PropTypes from 'react-native'