wlbreath
wlbreath

Reputation: 31

Browserify load fs return empty object

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();
           });
        });
    }
 }

Upvotes: 3

Views: 936

Answers (1)

Dan H
Dan H

Reputation: 3623

import * as fs from 'fs';

The module may not have a default export, so give that a shot.

Upvotes: 1

Related Questions