Search code examples
javascriptnode.jsgulpbrowserify

Gulp Error: Cannot find module browserify


Getting the above error when running gulp.

Can't figure out why. I've read a few things such as the gulp.src needs a ./ infront of app.

var gulp       = require('gulp'),
browserify = require('gulp-browserify');

gulp.task('scripts', function () {

gulp.src(['./app/main.js'])
    .pipe(browserify({
        debug: true,
        transform: [ 'reactify' ]
    }))
    .pipe(gulp.dest('./public/'));

});

gulp.task('default', ['scripts']);

Like so..

I've done a npm install so the node module is is where it should be. Its worth pointing out its called gulp-browserify in the node-module.

As well as I've installed browserify globally on my mac.

Let me know your thoughts or if there is any information im missing.

I'm new to react and trying to literally just set up node.js as a backend and create a react environment.


Solution

  • gulp-browserify was blacklisted by gulp

    You need to use browserify with vinyl-source-stream.

    var gulp = require('gulp');
    var browserify = require('browserify');
    var source     = require('vinyl-source-stream');
    
    gulp.task('browserify', function() {
        return browserify({ entries: ["./app/main.js"] })
            .bundle()
            .pipe(source('main.js'))
            .pipe(gulp.dest('./public/')));
    });
    

    Read more here.