Parse-sdk-js: RN crash with latest 1.10.1

Created on 23 Oct 2017  ·  24Comments  ·  Source: parse-community/Parse-SDK-JS

Hello.
This morning I've tried to update the package to the new release 1.10.1 but the packager returns this error:

error: bundling failed: UnableToResolveError: Unable to resolve module `react-native/Libraries/react-native/react-native.js` from `/<...app_path>/node_modules/parse/lib/react-native/StorageController.react-native.js`: Module does not exist in the module map

I think it may be related to https://github.com/parse-community/Parse-SDK-JS/commit/e0ac255e18706b0a2610e66bbdee4d52b72a0eff


Edit: I'm using react-native: 0.49.

Most helpful comment

In the meantime, as a workaround you can add a postinstall bash script in package.json. Something like:

#!/bin/bash
PARSE_FILENAME='./node_modules/parse/lib/react-native/StorageController.react-native.js'

sed -i '' -e '16,21d' $PARSE_FILENAME
sed -i '' -e 's|let AsyncStorage|let AsyncStorage = require("react-native/Libraries/Storage/AsyncStorage")|g' $PARSE_FILENAME

(OS X, Parse 1.10.1, RN 0.50)

All 24 comments

@kelset do you have the path where AsyncStorage is exposed on react-native: 0.49?

I'm not sure I've understood your question... by looking at the docs it doesn't seem AsyncStorage is exposed in any particular/new way...?

RN 0.49.3
Into ./node_modules/react-native/Libraries/Storage/AsyncStorage.js
@flovilmart

Wonderful!

TBH, it’s driving me crazy all those changes, would you guys be OK with providing the AsyncStorage class instead of the SDK fighting to figure out what to do?

@arniu thoughts?

RN 0.40.0 passed!

Yeah hopefully, and 0.43+ should pass now as well but 0.49 is broken

Same problem today when I upgraded Expo SDK to v22.0 (RN 0.49).

Solved it by putting back :

import { AsyncStorage } from 'react-native/Libraries/react-native/react-native-implementation';

instead of :

let AsyncStorage;
try {
// for React Native 0.43+
AsyncStorage = require('react-native/Libraries/react-native/react-native-implementation').AsyncStorage;
} catch (error) {
AsyncStorage = require('react-native/Libraries/react-native/react-native.js').AsyncStorage;
}

Any idea why it's working that way again ?

man it drives me crazy, we'Ll let you guys provide the async storage library on your own no? That seems safer for the long run

You mean like exposing an option to pass in to Parse the storage to use? (like redux-persist?)

Yep, that's the idea!

Please make it simple for beginners like me ! ^^

@AlexisJamin it's not about making it simple but just making it work.

I'm using react-native@^0.50.2 and I'm having the same issue. How can I fix this?

For RN 0.50.2, found the solution in parse/lib/react-native/StorageController.react-native.js. Changed to the following:

captura de pantalla 2017-11-07 a las 5 31 14 p m

Thanks @jcguarinpenaranda for the PR, can't wait for it to be merged & released :)

In the meantime, as a workaround you can add a postinstall bash script in package.json. Something like:

#!/bin/bash
PARSE_FILENAME='./node_modules/parse/lib/react-native/StorageController.react-native.js'

sed -i '' -e '16,21d' $PARSE_FILENAME
sed -i '' -e 's|let AsyncStorage|let AsyncStorage = require("react-native/Libraries/Storage/AsyncStorage")|g' $PARSE_FILENAME

(OS X, Parse 1.10.1, RN 0.50)

I'm using version 0.48.2 and every time I yarn it give me same error and I have to hard code!
I change

let AsyncStorage;
try {
  // for React Native 0.43+
  AsyncStorage = require('react-native/Libraries/react-native/react-native-implementation').AsyncStorage;
} catch (error) {
  AsyncStorage = require('react-native/Libraries/react-native/react-native.js').AsyncStorage;
}

to :

// let AsyncStorage;
// try {
  // for React Native 0.43+
  AsyncStorage = require('react-native/Libraries/react-native/react-native-implementation').AsyncStorage;
// } catch (error) {
//   AsyncStorage = require('react-native/Libraries/react-native/react-native.js').AsyncStorage;
// }

So it starts working well! any idea ?

Any update on when the fix for this (aside from the postinstall suggestion) will come out?

Asking because @natanrolnik merged the PR and then reverted it :/

Breaks with these:
"parse": "^1.10.2",
"react": "16.0.0",
"react-native": "0.50.3"

Replacing the AsyncStorage require in StorageController.react-native.js with this:
import { AsyncStorage } from "react-native/Libraries/react-native/react-native-implementation"; fixes things.

As things are turning I guess we’re gonna require the clients to set their async storage manually with something like Parse.setStorage()

Nice idea ! 😊

Alright, i’ll work on a PR for this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dblythy picture dblythy  ·  4Comments

futureinapps picture futureinapps  ·  3Comments

adrianchifor picture adrianchifor  ·  3Comments

Gyran picture Gyran  ·  5Comments

ryanemax picture ryanemax  ·  7Comments