2

I'm trying to include parse-react into my React Native project, but when running the app I'm getting the error in XCode and simulator:

Unable to resolve module ./lib/react-native/ParseReact.js from /Users/Corey/Work/example_app/node_modules/parse-react/react-native.js: Unable to find this module in its module map or any of the node_modules directories under /Users/Corey/Work/example_app/node_modules/parse-react/lib/react-native/ParseReact.js and its parent directories

I've included the two packages as such:

import Parse from 'parse/react-native';
import ParseReact from 'parse-react/react-native';

Looking in the node_modules/parse-react folder, the lib directory doesn't contain a react-native directory, but it does have the browser directory. I'm not sure if this is the problem or not, or how I'd go about getting that if it is.

I'm using react 0.14.7, react-native 0.21.0, parse 1.6.14, and parse-react 0.5.1.

Corey
  • 21
  • 1
  • 2

2 Answers2

0

I've had the same problem. I'm leaving my package.json here. Install accordingly, and you should be able to include parse modules into your project.

{
  "name": "commonDemo",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "parse": "^1.8.1",
    "parse-react": "^0.5.0",
    "react-native": "^0.20.0"
  }
}

Let me know if this works. Ideally, you should be able to include parse modules into your project using latest react-native release. But if using parse is absolutely necessary for your project, use this package.json.

To call Parse.initialize() use this-

var Parse = require('parse/react-native');

To call cloud functions and other functionality, use this-

var ParseReact = require('parse/react-native').Parse;

Mihir
  • 3,812
  • 3
  • 25
  • 29
  • 1
    Thanks Mihir, I tried using your `package.json`, but still encountered the same issue. I did *sort of* get around it (at least for the time being, this is by no means the long term solution) by cloning the current parse-react repo and running gulp to generate the `lib/react-native` directory, then added that to my project. – Corey Mar 29 '16 at 16:01
  • 1
    @Mihir it is `npm cache clean` – neoDev Dec 14 '16 at 05:36
  • @neoDev You're right. I always forget this. It's `npm cache clean` indeed. – Mihir Dec 14 '16 at 05:39
0

Look at the parse-react github README page. It says it works with version 1.6.14 of parse. It also says that 1.7 and 1.8 breaks compatibility. I had the same problem and downgrading to 1.6.14 solved the issue.

npm install parse@1.6.14 --save

  • Thanks for the replies @user3235983, and @Mihir. I was (and still am) using parse 1.6.14. I did upgrade to react-native 0.24.1 and now my `node_modules/parse-react/lib/react-native` directory does exists and everything is working correctly. I can't say that nothing else changed in the meantime but it is working. – Corey May 27 '16 at 16:24