Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Maxim Kontsevitch
Maxim Kontsevitch
25,447 Points

Gulp Error

Recently I started using gulp.js for my web-app. The web app is running on ruby on rails. Here is my code:

```var gulp = require('gulp'), coffee = require('gulp-coffee'), concat = require('gulp-concat'), uglify = require('gulp-uglify'), clean = require('gulp-clean'), sass = require('gulp-sass'), imagemin = require('gulp-imagemin');

var paths = { scripts: ['../javascripts//*.coffee', '../app/assets/scripts//.js'], styles: ['../stylesheets//.scss', '../app/assets/stylesheets//*.css'], images: ['../images//*'] };

gulp.task('scripts', function() { // Compile Coffescript, minify and uglify JS return gulp.src(paths.scripts) .pipe(coffee()) .pipe(uglify()) .pipe(concat('all.min.js')) .pipe(gulp.dest('../javascripts')); });

gulp.task('styles', function () { return gulp.src(paths.styles) .pipe(sass({style: 'compressed'})) .pipe(concat('main.css')) .pipe(gulp.dest('../stylesheets')); });

// Copy all static images gulp.task('images', function() { return gulp.src(paths.images) .pipe(imagemin({optimizationLevel: 5})) .pipe(gulp.dest('../images')); });

// Clean up the dist folder gulp.task('clean', function () { return gulp.src(['../stylesheets/', '../javascripts/', '../images/'], { read: false }).pipe(clean()); });

// Rerun the task when a file changes gulp.task('watch', function() { gulp.watch(paths.scripts, ['scripts']); gulp.watch(paths.styles, ['styles']); gulp.watch(paths.images, ['images']); });

gulp.task('build', ['scripts', 'styles', 'images']);

// The default task (called when you run gulp from cli) gulp.task('default', ['clean'], function() { gulp.start('build'); });

Here is my error:

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: source string:27: error: invalid top-level expression

1 Answer