3

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 ?

update : adding code

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>
    );
  }
});
Community
  • 1
  • 1
Amine Sadry
  • 153
  • 4
  • 11
  • Can you share your code where this happens? Did you import sendbird in your js file? – Orlando Jul 05 '16 at 07:28
  • Yes, actually the issue happens when i do require(''sendbird')... And i delete it everything works fine – Amine Sadry Jul 05 '16 at 14:03
  • In the error message does it look like it's looking for node_modules one level up from your project? – Dominic Jul 05 '16 at 14:06
  • Actually the ".../" before "/SendbirdSample" is just a replacement i did it to not type all my personal path to the projet... When i look inside node_modules, the sendbird library is present – Amine Sadry Jul 05 '16 at 15:01
  • 1
    Hi I'm having the exact same problem. Any update? – Pav Jul 07 '16 at 15:46
  • no, unfortunately i didn't have time to investigate more... i will give it a try this weekend and see what happens – Amine Sadry Jul 07 '16 at 19:52

2 Answers2

6

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 sendbird@2.4.18 and react-native@0.27.2.

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 PACKAGE_NAME@MAJOR.MINOR.PATCH, e.g.

npm i --save sendbird@2.4.18.

You can view all available versions of the sdk by running

npm info sendbird.

NiFi
  • 2,398
  • 1
  • 17
  • 26
1

The official word I got from Sendbird when I reported the same issue. I haven't tried the newly released 3.0. So can't speak to that.

Harry Kim (SendBird) Jul 6, 01:51 PDT

Thank you for contacting SendBird support.

We recommend to use below packages to run SendBird properly.

"react-native": "0.20.0",
"react-native-button": "1.4.2",
"react-native-gifted-messenger": "0.0.18",
"react-native-gifted-spinner": "0.0.3",
"react-native-popup": "0.5.2",
"sendbird": "^2.4.20"

Regard, Harry

Community
  • 1
  • 1