tradle / rn-nodeify

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

undefined is not a function (evaluating 'fs.existsSync(dirPath)') #81

Closed curtismenmuir closed 5 years ago

curtismenmuir commented 5 years ago

I am trying to get Winston (Version 3.X) logger to work on React-Native using RN-Nodeify (what a package, thank you! <3) and I am stuck at an issue with fs.existsSync() when trying to output the logs to a file.

Screenshot_20190611-154341

Postinstall script used: "postinstall": "rn-nodeify --install util,buffer,os,fs,path,zlib,http,https,_stream_transform,assert,events,url,stream,process,tls,global,crypto,vm --hack"

Index.js - from line 1 (app entry point):

import "./shim";
global.Symbol = require("core-js/es6/symbol");
require("core-js/fn/symbol/iterator");
require("core-js/fn/map");
require("core-js/fn/set");
require("core-js/fn/array/find");
var fs = require("react-native-level-fs");
import { Navigation } from "react-native-navigation";
...

Is there any way to get round this issue with RN-Nodeify?

mvayngrib commented 5 years ago

unfortunately fs.existsSync (along with many other synchronous methods) is not supported at the moment. RN introduced the ability to make calls over the bridge synchronously only a few versions ago. You can add support to react-native-level-fs if you want :)

curtismenmuir commented 5 years ago

@mvayngrib Thanks for getting back to me! :)

Thanks for the heads up, I will have a look into react-native-level-fs. Closing this issue!