I am following sendbird's tutorial on building a chat app with react-native, and i get the following error when I try to import 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
I deleted node_modules folder and run npm install again, cleaned npm cache and cleared watchman watches but couldn't fix it.
Any thoughts on this issue ?
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; } } />
);
}});
login.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; } } />
);
}
});
channels.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>
);
}
});
Try using an earlier version of SendBird's JS SDK. Based on my own testing this issue is introduced in SDK v. 2.4.19. My setup works with [email protected] and [email protected].
The sudden appearance of this problem in a patch strongly suggests a bug in the SDK or the introduction of an undocumented API change (changelog), which is basically a bug as well.
To install a specific version of an npm package:
npm i --save [email protected], e.g.
npm i --save [email protected].
You can view all available versions of the sdk by running
npm info sendbird.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With