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

Can't use in React Native #88

Open
tinaroh opened this issue Oct 25, 2018 · 0 comments
Open

Can't use in React Native #88

tinaroh opened this issue Oct 25, 2018 · 0 comments

Comments

@tinaroh
Copy link

tinaroh commented Oct 25, 2018

I'm trying to use this library in a React Native app for localization but I'm having trouble with the following error:

Error: Unable to resolve module `assert` from `/Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/cldr-data/index.js`: Module `assert` does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968
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 Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
    at ModuleResolver.resolveDependency (/Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:209:1301)
    at ResolutionRequest.resolveDependency (/Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:83:16)
    at DependencyGraph.resolveDependency (/Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/metro/src/node-haste/DependencyGraph.js:238:485)
    at Object.resolve (/Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/metro/src/lib/transformHelpers.js:180:25)
    at dependencies.map.result (/Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:311:29)
    at Array.map (<anonymous>)
    at resolveDependencies (/Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:307:16)
    at /Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:164:33
    at Generator.next (<anonymous>)
    at step (/Users/tinaroh/Dev/Raha/raha-mobile-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:266:307)

I tried the listed workarounds in the mentioned issue but have had no luck.

For set up I did: yarn add react-globalize cldr-data (we use yarn instead of npm)

Initialization in the file with the component:

var ReactGlobalize = require("react-globalize");
var Globalize = require("globalize");
Globalize.load(require("cldr-data").entireSupplemental());
Globalize.load(require("cldr-data").entireMainFor("en", "de"));

Call-site in the render function within the same file:

{new Globalize("de").numberFormatter({ minimumFractionDigits: 2 })(10)}

(tried the static version too)

I'm pretty new to JavaScript/React. I heard that there are differences with the React Native JS and web JS, could that be what's tripping this up? Though I feel like assert should be in both... Is there something special I need to do for React Native?

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

1 participant