McBooley McBooley - 1 year ago 395
Javascript Question

Gulp TypeError: dest.on is not a function

I'm trying to generate a bundle.js with a Gulp task

var gulp = require('gulp'),
gutil = require('gulp-util'),
wrench = require('wrench'),
conf = require('./webpack.config'),
webpack = require('webpack'),
WebpackDevServer = require('webpack-dev-server');

// Webpack
gulp.task('wp', function() {
return gulp.src('./assets/scripts/entry.js')

and when I try to run it, I get TypeError: dest.on is not a function.
enter image description here

enter image description here

Also here's the folder directory

Answer Source

The error occurs because webpack doesn't work natively with gulp streams. Naturally the returned object by webpack() doesn't include dest.on which is specific to gulp.

Either use gulp-webpack or follow the official docs on how to use webpack with gulp

Sample code taken straight out of the official docs which uses webpack-stream:

var gulp = require('gulp');
var webpack = require('webpack-stream');

gulp.task('default', function() {
  return gulp.src('src/entry.js')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download