How to run gulp tasks in terminal
Asked Answered
H

4

26

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
        }));

})
Hirundine answered 6/7, 2017 at 18:1 Comment(4)
Your file should be named gulpfile.js. Then you do gulp task1 in the terminalExtranuclear
have you installed gulp?Infectious
@arun what happens when you do gulp -v? Does it show you the gulp version?Stickup
Yes its worked by changing gulp.js to gulpfile.jsHirundine
S
25

Have you install Gulp on NPM?. If not, do the following.

$ npm install gulp
$ npm install jshint gulp-jshint --save-dev
$ npm install --save-dev gulp-jscs

In case it's not installed, try to:

$ sudo npm install -g gulp
$ sudo npm install -g jshint gulp-jshint --save-dev
$ sudo npm install -g --save-dev gulp-jscs

After completing the installation, try gulp on terminal (Remember that you must be in the same directory of the file).

Strung answered 6/7, 2017 at 20:30 Comment(0)
E
6

In addition to making sure you have gulp globally installed, make sure your gulp file is named *gulpfile.js* and that is in the same directory as where you are running gulp. Then simply run gulp task1. If you run gulp without anything else, the default task will run (you can write a task named "default" which will be run in this case.

Extranuclear answered 6/7, 2017 at 20:35 Comment(0)
T
3
  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
Trisa answered 27/3, 2022 at 14:35 Comment(0)
L
-2

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
Lattermost answered 6/8, 2018 at 14:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.