antoniopresto / react-native-local-mongodb

react-native local mongodb storage.
MIT License
304 stars 66 forks source link

Can't import this lib in expo apps #35

Closed aalhaimi closed 6 years ago

aalhaimi commented 6 years ago

Hi there,

I'm getting the following error when I just add the require statement and initiate the datastore in a new Expo sample app. Not sure if this is compatible or have to detach to use this lib.

screen shot 2018-06-01 at 12 44 27 am
aalhaimi commented 6 years ago

fixed this issue.. I had to upgrade node and npm to the latest version. sorry!

for anyone who might be facing this issue, checkout the dependencies of this package, and if you're using any of these dependencies in your package, make sure to use the same version as required by react-native-local-mongodb otherwise the app will crash like this as well.

If this happens, just do:

  1. npm uninstall react-native-local-mongodb
  2. uninstall the conflicting package(s)
  3. update your package.json with the compatible packages or npm install [package with compatible version no]
  4. npm i.
mjmasn commented 6 years ago

For anyone else coming across this issue where you are using a more modern version of underscore elsewhere, you can also update your package.json as follows:

{
  "dependencies": {
    "underscore": "1.8.3"
  },
  "resolutions": {
    "underscore": "1.8.3"
  }
}

The resolutions section forces underscore 1.8.3 to be used instead of 1.4.4. Change this version to match the one in your dependencies section then run yarn again.

antoniopresto commented 6 years ago

Thanks, @mjmasn and @aalhaimi! Can you send a pr, please? I can not test this fix in expo for now

mjmasn commented 6 years ago

@antoniopresto just to clarify we're not using expo but we get the same error.

I can't remember exactly what I found when I dug into this issue a while ago but it seemed like updating the version of underscore used in this package to 1.8.3 or 1.9.1 would probably resolve the issue, regardless of other versions we might be using in the app (we use 1.8.3 because 1.9.x has some bad breaking changes). Is there any particular reason you're using Underscore 1.4.4 (now ~5½ years old)?

antoniopresto commented 6 years ago

this library is a fork from nedb, most of it came from the original library. I'll check this issue and maybe upgrade the underscore version, but first I need to cover more test cases.

mjmasn commented 6 years ago

Thanks for looking into it, if it helps the underscore methods used here are:

omit 
intersection 
pluck 
uniq 
has 
map 
filter 
isFunction 
isBoolean 

The only changelog items I could find for those were from 1.7.0:

_.has now guards against nullish objects.
_.omit can now take an iteratee function.