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

Math.js blocks React Native production bundling #797

jonrh opened this Issue Feb 21, 2017 · 5 comments


None yet
2 participants

jonrh commented Feb 21, 2017

Hi! First let me just say thank you to all the contributors for their hard work on this brilliant library, keep up the good work!

Problem description

React Native is library/framework to make native mobile apps with JavaScript. When using math.js v3.9.2 as a dependency production builds can no longer be created with the React Native packager. Development builds work correctly (running in a simulator, etc) but not production builds (which are required to publish apps).

Related GitHub issues:


I created a small sample React Native project where I investigated a bit the cause of the problem. In the project readme I trace and document things as I went along. The problem can be reproduced by attempting to create a production bundle with the React Native packager by running the following command:

react-native bundle --dev=false --platform=ios --entry-file=index.ios.js --bundle-output something.jsbundle

This produces the following error message:

➜ react-native-mathjs-bug git:(master) ✗ react-native bundle --dev=false --platform=ios --entry-file=index.ios.js --bundle-output 	something.jsbundle
Loading dependency graph, done.

Unable to resolve module crypto from /Users/jonrh/Desktop/react-native-mathjs-bug/node_modules/decimal.js/decimal.js:
Module does not exist in the module map or in these directories: /Users/jonrh/Desktop/react-native-mathjs-bug/node_modules

This might be related to
To resolve try the following:
	1. Clear watchman watches: `watchman watch-del-all`.
	2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
	3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.

For reference I did attempt the above instructions but without success.

Potential solution

Upgrade decimal.js dependency from v5.0.8 to at least v7.1.1. See here for rationale.

Temporary fix

To be able to make production builds in React Native one possible temporary solution would be to replace the contents of the file node_modules/decimal.js/decimal.js with that of the fixed file here. Raw content link.

Other information

This may not inherently be the fault of decimal.js nor math.js but rather the React Native packager itself. I'm not too sure about it but given that decimal.js v7.1.1 seems to work without issues I'm optimistic that if upgraded this might at least solve the conflict between Math.js and React Native. Thank you for your time and devotion!


This comment has been minimized.


josdejong commented Feb 21, 2017

Thanks for your detailed description problem description Jon. This sounds like a really easy fix :).

I've upgraded the version of decimal.js in the develop branch, and will do a bug fix release tomorrow (or maybe in two days).


This comment has been minimized.

jonrh commented Feb 21, 2017

Brilliant! Thanks so much Jos for your super fast resolve.

@josdejong josdejong closed this in 6f7fc17 Feb 22, 2017


This comment has been minimized.


josdejong commented Feb 22, 2017

I'm not always that fast but I'm trying my best :)

I've just released math.js v3.9.3 containing the updated version of decimal.js. Would be great if you could verify whether this actually solves the issue.


This comment has been minimized.

jonrh commented Feb 23, 2017

Confirmed, updated to v3.9.3 and the React packager is now able to create production bundles. Thanks a lot for your swift response!


This comment has been minimized.


josdejong commented Feb 23, 2017

Awesome! thanks for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment