Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React-Native issue #72

Open
raynoppe opened this issue Apr 11, 2017 · 5 comments
Open

React-Native issue #72

raynoppe opened this issue Apr 11, 2017 · 5 comments

Comments

@raynoppe
Copy link

Hi

I get the following error when I run the following:

import PouchDB from 'pouchdb-react-native';
PouchDB.plugin(require('pouchdb-find'));
PouchDB.plugin(require('pouchdb-quick-search')); // <= causes the error

Error:
Unable to resolve module crypto from /Users/raynoppe/Sites/reactNative/mapped/node_modules/pouchdb-quick-search/lib/pouch-utils.js: Module does not exist in the module map or in these directories:
/Users/raynoppe/Sites/reactNative/mapped/node_modules/pouchdb-quick-search/node_modules
, /Users/raynoppe/Sites/reactNative/mapped/node_modules

I installed crypto via nom and still the same error.

Thank you

@raynoppe
Copy link
Author

Got it to work. Had to do the following:
Install https://github.com/mvayngrib/react-native-crypto follow the workflow.

In the lib/pouch-utils.js change line 79 from 'var crypto = require('crypto');' to 'var crypto = require('react-native-crypto');' and it works 👍

@mark922
Copy link

mark922 commented Dec 22, 2018

I had the same problem in Angular 7. This helped: Reference Patch

@gstvg
Copy link

gstvg commented Jun 3, 2019

Faced the same problem. I'm using my fork gstvg/pouchdb-quick-search. To use this, just put on package.json:
"pouchdb-quick-search": "https://github.com/gstvg/pouchdb-quick-search/tarball/master",

@duytq94
Copy link

duytq94 commented Jun 18, 2019

Solution of @gstvg works fine on React Native.
Thank you very much.

@leonid-shevtsov
Copy link

leonid-shevtsov commented Aug 14, 2019

The crypto module is only needed to build an md5 hash.

https://github.com/pouchdb-community/pouchdb-quick-search/blob/master/lib/pouch-utils.js#L79

Seeing as react-native-crypto is not a perfect drop-in replacement for crypto, a more robust solution would be to

  1. not require crypto if it's not needed
  2. switch to a better env detection than checking for process.browser

My quick fix was replacing the whole code block with a call to the md5 library
leonid-shevtsov@9bf91d6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants