tradle / rn-nodeify

hack to allow react-native projects to use node core modules, and npm modules that use them
MIT License
618 stars 112 forks source link

Error: readFileSync function from `fs` is undefined #110

Closed JonasHiltl closed 2 years ago

JonasHiltl commented 3 years ago

A package that I use uses the fs module to read another file with the readFileSync function. But my app throws an error when calling the readFileSync function, because the function is udefined. This is the error:

 TypeError: _$$_REQUIRE(_dependencyMap[6], "fs").readFileSync is not a function. (In '_$$_REQUIRE(_dependencyMap[6], "fs").readFileSync(path)', '_$$_REQUIRE(_dependencyMap[6], "fs").rea_dependencyMap[6], "fs").readFileSync' is undefined)

Below is the conflicting line that uses readFileSync

const path = require('path').join(__dirname, 'identity_wasm_bg.wasm');
const bytes = require('fs').readFileSync(path);

These are my node modules I shim:

"postinstall": "rn-nodeify --install fs,util,process,path,events,stream --hack --yarn"

I also import the shim.js file.

mvayngrib commented 2 years ago

yes, readFileSync is not yet supported. PRs welcome here: https://github.com/tradle/react-native-level-fs