我正在关注 sendbird 的关于使用 react-native 构建聊天应用程序的教程,当我尝试导入 sendbird sdk 时出现以下错误:
Unable to resolve module http from .../SendbirdSample/node_modules/sendbird/SendBird.min.js:
Unable to find this module in its module map or any of the node_modules/http and its parent directories
我删除了 node_modules 文件夹并再次运行 npm install,清理了 npm 缓存并清除了 watchman 手表,但无法修复它。
对这个问题有什么想法吗?
更新:添加代码
main.js
import React from 'react';
import {
StyleSheet,
Navigator
} from 'react-native';
var Login = require('./components/login');
var Channels = require('./components/channels');
var ROUTES = {
login: Login,
channels: Channels
};
module.exports = React.createClass({
renderScene: function(route, navigator) {
var Component = ROUTES[route.name];
return <Component route={route} navigator={navigator} />;
},
render: function() {
return (
<Navigator
style = { styles.container }
initialRoute={ {name:'login'} }
renderScene={this.renderScene }
configureScene={ () => { return Navigator.SceneConfigs.FloatFromRight; } } />
);
}});
登录.js
import React from 'react';
import {
StyleSheet,
Navigator
} from 'react-native';
var Login = require('./components/login');
var Channels = require('./components/channels');
var ROUTES = {
login: Login,
channels: Channels
};
module.exports = React.createClass({
renderScene: function(route, navigator) {
var Component = ROUTES[route.name];
return <Component route={route} navigator={navigator} />;
},
render: function() {
return (
<Navigator
style = { styles.container }
initialRoute={ {name:'login'} }
renderScene={this.renderScene }
configureScene={ () => { return Navigator.SceneConfigs.FloatFromRight; } } />
);
}
});
频道.js
import React from 'react';
import {
View,
Text,
StyleSheet
} from 'react-native';
var sendbird = require('sendbird');
module.exports = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={{color: '#fff'}}>Channels</Text>
</View>
);
}
});