// No problem at all with this code
import {View, Text} from 'react-native'
const App = () => {
return (
<View>
<Text>
Test
</Text>
</View>
)
}
export default App
OUTPUT: LOG Running "Chat" with {"rootTag":161,"initialProps":{}}
info Reloading app...
BUNDLE ./index.js
********************************************
// but as soon as I import
import {View, Text} from 'react-native'
import {Voximplant} from 'react-native-voximplant'; <--
const client = Voximplant.getInstance(); <--
const App = () => {
return (
<View>
<Text>
Test
</Text>
</View>
)
}
export default App
// I get the following.
OUTPUT: LOG Running "Chat" with {"rootTag":171,"initialProps":{}}
ERROR Invariant Violation: `new NativeEventEmitter()` requires a non-null argument., js engine: hermes
我已经尝试了GitHub上所有最新的答案和堆栈溢出,但没有一个工作。在这一点上,我不知道该怎么办。做这个问题,我无法使用Voximplant。
{“name”:“聊天”,“version”:“0.0.1”,“private”:true,“scripts”:{“android”:“react-native run-android”,“ios”:“react-native run-ios”,“lint”:“eslint .",“start”:“react-native start”,“test”:“jest”},“dependencies”:{“react”:“18.2.0”,“react-native”:“0.71.5”,“react-native-voximplant”:“^1.36.0”},“devDependencies”:{“@babel/core”:“^7.20.0”,“@babel/preset-env”:“^7.20.0”,“@babel/runtime”:“^7.20.0”,“@react-native-community/eslint-config”:“^3.2.0”,“@tsconfig/react-native”:“^2.0.2”,“@types/jest”:“^29.2.1”,“@types/react”:“^18.0.24”,“@types/react-test-renderer”:“^18.0.0”,“babel-jest”:“^29.2.1”,“eslint”:“^8.19.0”,“jest”:“^29.2.1”,“metro-react-native-babel-preset”:“0.73.9”,“更漂亮”:“^2.4.1”,“react-test-renderer”:“18.2.0”,“typescript”:“4.8.4”},“jest”:{“预设”:“react-native”} }
目前运行在MacBook Pro M2上,操作系统:macOS Ventura版本13.3
1条答案
按热度按时间tcbh2hod1#
只是为了确认一下,在添加新模块后,你是否在ios文件夹中运行了
pod install
?当你安装了一个新模块,但没有为iOS开发生成pod时,这看起来像是一个错误。
步骤:
1.导航到react-native项目中的ios文件夹。
1.从终端运行
pod install
。1.在Xcode上,使用快捷方式
cmd+shift+k
清理项目。(专业提示:您可以删除~/Library/Developer/XCode/DerivedData中的DerivedData文件夹,它将在您成功构建应用程序后重新生成)。1.构建您的应用程序(
cmd+r
);