Recently, I started diving into the world of gulp
and browserify
. Here's the setup in my gulpfile.js
:
gulp.task('default', function (done) {
var b = browserify({
entries: ['app/app.js'],
});
var browserifiedCode = b
.transform(bulkify)
.bundle()
.on('error', function(err) {
gutil.log('Browserify Error', gutil.colors.red(err));
gutil.beep();
this.emit('end');
})
.pipe(source('app.browserified.js')) --> what does it mean ??
.pipe(buffer());
var nonBrowserifyLibraries = [];
var output = gulpMerge(
gulp.src(nonBrowserifyLibraries),
browserifiedCode
)
.pipe(concat('app.js'));
//output = output.pipe(uglify());
return output.pipe(gulp.dest('./'));
Upon running gulp
, it successfully creates app.js
. However, the browser throws an error
Uncaught TypeError: fs.readdirSync is not a function
when trying to run it.
Any suggestions or solutions would be greatly appreciated.
Thank you
EDITED: I have identified that the issue lies with bulk-require
which uses fs.readdirSync(abc)
. When attempting to browserify manually using browserify app/app.js -o app.js
and loading the app.js
in the browser, the same fs.readdirSync
error persists.