Open dannydolph opened 6 years ago
@dannydolph you’ll need to use a library like react-native-fs
to read the filesystem, the fs
library is native to node and it will not exist in an environment like react native.
This basically means that you can’t use the NodeFileReader
class to read the files. You’ll need to implement a new one that specifically knows how to read files in RN. You should be able to use NodeFileReader
as a template. It would also be great if you can contribute with this new reader to the repo :)).
@aadsm I'm currently taking a stab at this and there are a couple of hurdles that are difficult.
NodeFileReader
or the build error will still exist. This differs from the browserify solution ignoring the NodeFileReader
since the build pipeline is different.require
s aren't supported by react-native
so I'm not sure how to deal with conditional builds for the node vs React-Native versions.react-native-fs
is promise-based. Support for promises with this library would be nice. Translating between callbacks/promises works but is a bit awkward.react-native-fs
recommends base64
for binary, but I'm not sure if the tags are treated differently or what this library expects. Here's my current implementation https://github.com/davidroeca/jsmediatags/blob/react-native/src/ReactNativeFileReader.js
Let me know if you have any insight on any of the above.
I'm using jsmediatags in an React-Native application (a music player) and I get this error as soon as I require or import this package :
bundling failed: UnableToResolveError: Unable to resolve module 'fs'