How to run gulp tasks in terminal

Viewed 54084

I am a beginner in gulp. I have created a task named task1 in gulp.js and when i tried to execute that task using "gulp task1" in command line, Its opening the gulp.js file on brackets editor rather than executing in command line. Can somebody help me in solving this problem

The code in my gulp file is

var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');


gulp.task('task1', function () {
    return gulp
        .src(['./src/**/x.js', './*.js'])
        .pipe(jscs())
        .pipe(jshint())
        .pipe(jshint.reporter('jshint-stylish', {
            verbose: true
        }));

})
4 Answers
  1. install gulpJS
  2. export the task1 in the gulpFile.js

module.exports = task1

  1. run the below command in terminal
gulp task1 

or

gulp

Install gulp globally and run the gulp command from the folder the 'gulpfile.js' is located

npm install gulp-cli -g
npm install gulp -D
Related