Browserify load fs return empty object


#1

I’m new to Electron, I use react to build my application, and I use browserify to compile jsx to js and es6 to es5, but when I use import to add the fs module( import fs from “fs” ), it return a empty object. I guess I it may be the compiled file uses browserify’s “require” to load module fs rather than node’s “require”. And when load the fs module, browserify return a empty object directly. how can i solve this problem:joy:

import fs from 'fs';

class MyFS {

    static mkdir(path, mode){
 	    mode = mode || 0o777;

	    return new Promise(function(resolve, reject){
		    fs.mkdir(path, mode, function(err){
			    if(err){
				    reject(err);
				    return;
			    }

			    resolve();
		    });
	     });
     }
 }

#2

I am facing the same issue also if you use the below command, it will work, which is actually setting the "fs":undefined , I am still trying to find the equivalent of this command in Gulp , so I can do it programmatically.

browserify -t es6ify -x ./node_modules/electron/**/*.js --node ./app/app.js -o ./dist/bundle.js

I hope this help.