I am using this library in my React Native app, but I am having a problem as it tries to require
crypto. In a node environment, require
-ing an unavailable module would throw an Error, which could then be caught and handled. However, the packager will not package the app as it couldn't resolve the module. Is there any way to ignore these errors and just have an error thrown on runtime?
Asked
Active
Viewed 85 times
0

John Leuenhagen
- 576
- 7
- 23
-
Did you notice the build of that package is failing! – Rajendran Nadar Mar 31 '18 at 16:21
-
@RaajNadar I checked the build log, and it seems like it failed just because the connection to github timed out. I am able to use the library just fine in node. – John Leuenhagen Mar 31 '18 at 16:23
-
Stop and start the packager again.. – Rajendran Nadar Mar 31 '18 at 16:25
-
@RaajNadar how would that help? The module will still try to require a package that isn't installed... I have restarted it several times with no results by the way. – John Leuenhagen Mar 31 '18 at 16:26
-
Maybe you are missing any dependencies? – Rajendran Nadar Mar 31 '18 at 16:27
-
@RaajNadar maybe my question isn't clear enough. I know that I am missing the module that I am trying to require, and I won't be able to easily change that. However, the module encloses the `require` call in a try block, so it is normally able to detect when the require fails and can then use a fallback. However, the RN packager will not package the app at all, meaning that the fallback can not be used. – John Leuenhagen Mar 31 '18 at 16:32
-
Why don't you edit the file inside node_modules and remove that require? – Rajendran Nadar Apr 01 '18 at 02:48
-
@RaajNadar that way I would have to edit that file every time I clone the repository. Theoretically it would work, but I'm not willing to commit that solution. – John Leuenhagen Apr 01 '18 at 04:04
-
Send a pull request! – Rajendran Nadar Apr 01 '18 at 04:07
-
@RaajNadar The thing that I'd be removing is important to keep normally. The only reason why I'm trying to remove it is because React Native doesn't support it. – John Leuenhagen Apr 01 '18 at 05:39