Lucky Lam
Lucky Lam

Reputation: 145

Gulp Browserify ReferenceError: source is not defined

I'm getting this odd error as the title. The full message looks like this

$ gulp browserify [01:21:03] Using gulpfile F:\CSC Assignments\FinalProject\HotelProject\gulpfile.js [01:21:03] Starting 'browserify'... [01:21:03] 'browserify' errored after 15 ms [01:21:03] ReferenceError: source is not defined at Gulp. (F:\CSC Assignments\FinalProject\HotelProject\gulpfile.js:109:15) at module.exports (F:\CSC Assignments\FinalProject\HotelProject\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7) at Gulp.Orchestrator._runTask (F:\CSC Assignments\FinalProject\HotelProject\node_modules\gulp\node_modules\orchestrator\index.js:273:3) at Gulp.Orchestrator._runStep (F:\CSC Assignments\FinalProject\HotelProject\node_modules\gulp\node_modules\orchestrator\index.js:214:10) at Gulp.Orchestrator.start (F:\CSC Assignments\FinalProject\HotelProject\node_modules\gulp\node_modules\orchestrator\index.js:134:8) at C:\Users\LUCKYLAM\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20 at process._tickCallback (node.js:355:11) at Function.Module.runMain (module.js:503:11) at startup (node.js:129:16) at node.js:814:3

I'm new to this and after having spent a couple of hours figuring out what's causing the problem I have no idea what is wrong around here. Please help.

Here is my /app/js/script.js

require('angular');

var app = angular.module('app', []);

gulpfile.js:

gulp.task('browserify', function() {
    return browserify('./app/js/script.js')
        .bundle()
        .pipe(source('main.js'))

        // saves it the public/js/ directory
        .pipe(gulp.dest('./dist/js/kk/'));
});

My folder structureenter image description here

Upvotes: 4

Views: 4310

Answers (1)

aprok
aprok

Reputation: 1157

I guess you are missing one npm package: vinyl-source-stream.

Try to install it with npm install vinyl-source-stream --save-dev and require in your gulpfile.js like so:

var source = require('vinyl-source-stream');

Upvotes: 13

Related Questions