question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

exception: browserify + vinyl-transform

See original GitHub issue

Hi,

It’s my gulpfile.js setting.

//gulpfile.js

var gulp = require("gulp");
var browserify = require("browserify");
var transform = require("vinyl-transform");
var rename = require("gulp-rename");

gulp.task("scripts", function () {
    var browserified = transform(function (filename) {
        var b = browserify(filename);

        return b.bundle();
    });

    return gulp.src([
        "./test/myApp/_module.js"
    ])
    .pipe(browserified)
    .pipe(rename("app.js"))
    .pipe(gulp.dest("./test/"));
});

When I use latest version of browserify, this exception are as follows.

_stream_readable.js:540
    var ret = dest.write(chunk);
                   ^
TypeError: undefined is not a function
    at Producer.ondata (_stream_readable.js:540:20)
    at Producer.emit (events.js:107:17)
    at Producer.Readable.read (_stream_readable.js:373:10)
    at flow (_stream_readable.js:750:26)
    at resume_ (_stream_readable.js:730:3)
    at _stream_readable.js:717:7
    at process._tickCallback (node.js:355:11)
Process terminated with code 1.

However, I downgrade to v9.0.4, anything will be ok. Who can talk me how to fix it ?

thanks

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12

github_iconTop GitHub Comments

2reactions
iamcdonaldcommented, Apr 6, 2015

HI Bibby,

there seem to be a couple of other issues raised around this topic.

Paraphrasing here but, browserify’s bundle() is documented as returning readable stream whereas vinyl-transform expects a transform/duplex stream which is readable and writeable. This worked in the past as .bundle() was at times returning a duplex stream however this is now fixed in line with the docs.

I’m currently using ‘through2’ and something akin to the following

gulp.src('./src/index.js')
    .pipe(through2.obj(function (file, enc, next){
            browserify(file.path)
                .transform('stripify')
                .bundle(function(err, res){
                    // assumes file.contents is a Buffer
                    file.contents = res;
                    next(null, file);
                });
        }))
    .pipe(gulp.dest('./build/'))

which was taken from aymanrady on this thread which has a few other recipes for using browserify within gulp.

Hope that helps.

1reaction
philkunzcommented, Oct 27, 2015

If someone is looking for an easy approach: check out our https://www.npmjs.com/package/gulp-browser package

It works with the latest browserify and bundles any “require” by default.

var gulp = require("gulp");
var gulpBrowser = require("gulp-browser");

gulp.task('gulpBrowserTest',function() {
    var stream = gulp.src('./test/*.js')
        .pipe(gulpBrowser.browserify())
        .pipe(gulp.dest("./test/browserifiedJS/"));
    return stream;
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

task-browserify@0.0.1 vulnerabilities - Snyk
Learn more about task-browserify@0.0.1 vulnerabilities. task-browserify@0.0.1 has 20 known vulnerabilities found in 48 vulnerable paths.
Read more >
gulp + browserify, the gulp-y way | by Hafiz Ismail - wehavefaces
We only need vinyl-transform to make this all work, which is still a useful library for your other gulp needs. Using gulp-browserify. var...
Read more >
Browserify building with dependencies that have require ...
I'm trying to use timbre.js (npm version) with Browserify, but it has require statements for optional dependencies in a try statement (see ...
Read more >
Development and Such — Gulp, Browserify, and Source Maps
Gulp, Browserify, and Source Maps The worst thing about Browserify is the need for source ... This warning and the subsequent exception:
Read more >
Open Source Disclosure — Cloudvue Video Surveillance and ...
Babel browserify transform ... vinyl-transform ... However, as a special exception, the source code distributed need not include anything that is normally ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found