0

I'm trying to utilize a vcard parsing module written in Javascrip but it relies on node.js core modules, fs and path. My application is written in React-Native. Does anyone have any recommendations as to how I can emulate the file-system and path modules of npm for use inside the vcard parsing javascript module?

The file in question is the index file of vcards-js and is located inside my node_modules folder of my application. So app/node_modules/vcards-js/index.js

var fs = require('fs');
var path = require('path');
2
  • Look at browserify. Commented Jul 28, 2016 at 18:44
  • React Native is not running on Node, it's running on a pure Javascript environment, not only node API won't work, many Web API does not work either. Commented Aug 31, 2016 at 2:02

1 Answer 1

1

I forked vCards JS for use with React Native: https://github.com/idxbroker/vCards-js/tree/react-native

Instead of trying to emulate fs one to one, I use a package: react-native-fs Which has very similar methods and functionality as the Node equivalent. vCards JS only required minimal adjustments.

Feel free to use this version.

npm install react-native-vcards@https://github.com/idxbroker/vCards-js.git#react-native --save
Sign up to request clarification or add additional context in comments.

2 Comments

It's funny you mention this because it's something I've actually already tried but couldn't quite get it to work @Daniel IDXBroker. FYI there is no directory at reart-native-vcards. If you have a working version, I would love to use yours
Sorry, we changed the repo name right after I posted this. I updated the original post to reflect the new repo location.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.