0

I trying to set up an project with pre processing with gulp in Visual Studio Code. I have installed gulp using npm: npm install gulp --save en installed it also globally.

Added some tasks in my gulpfile.js and filled the tasks.json file in Studio Code with details.

When I run the scripts, Studio keep saying 'gulp is not recognized as an internal of external command'. I have add 'NODE_PATH' as system variabele, and i'm able to start gulp manually via command line. (npm run gulp).

What I'm doing wrong?

What I did so far:

Added script: gulp:gulp to my package.json (as seen on https://stackoverflow.com/a/32569658/4548006)

Installed modules:

  • npm
  • gulp
  • gulp-styles
  • gulp-uglify
  • gulp-pug
  • gulp-pug2

gulpfile.js

var gulp = require('gulp');
var uglify = require('gulp-uglify');
var pump = require('pump');
var pug = require('gulp-pug2');
var stylus = require('gulp-stylus');

gulp.task('default', function(){
    gulp.watch([
        'app/app.js',
        'app/routes/routes.js',
        'app/controllers/**.js',
        'app/directives/**.js',
        'app/services/**.js',
        'app/libs/**.js',], ['scripts', 'scripts-minify']);
    gulp.watch([
        'app/partials/**.pug',
        'app/index.pug'], ['views-compile']);
    gulp.watch([
        'app/style/**.style'], ['stylus']);

})

gulp.task('stylus', function(){
    return gulp.src([
        'app/style/**.style'
    ])
    .pipe(stylus({
        compress:true
    }))
    .pipe(gulp.dest('app/views/css/'))
})

gulp.task('views-compile', function(){
    return gulp.src([
        'app/partials/**.pug',
        'app/index.pug'
    ])
    .pipe(pug.compile())
    .pipe(gulp.dest('app/views'))
})

gulp.task('scripts', function(){
    return gulp.src([
        'app/app.js',
        'app/routes/routes.js',
        'app/controllers/**.js',
        'app/directives/**.js',
        'app/services/**.js',
        'app/libs/**.js']
    )
    .pipe(concat('scripts.js'))
    .pipe(gulp.dest('app/scripts/'))
})

gulp.task('scripts-minify', function(){
    return gulp.src([
        'app/scripts/scripts.js']
    )
    .pipe(concat('scripts.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('app/scripts/'))
});

Tasks.json

{
    "version": "0.1.0",
    "command": "gulp",
    "isShellCommand": true,
    "tasks": [
        {
            "taskName": "default",
            "isBuildCommand": true,
            "showOutput": "always",
            "isWatching": true
        }
    ]
}
Community
  • 1
  • 1
NVO
  • 2,566
  • 5
  • 27
  • 57
  • 1
    `npm install gulp --save` doesn't install gulp globally. `npm install -g gulp` would install it globally. Did you log out and in again? Windows doesn't like renewing the environment variables while you're logged in. – SplittyDev Dec 20 '16 at 10:40
  • after several gulp and gulp-cli install - no luck for me. even tried npm link gulp. only after system restart, gulp command starts working. – Sparkz Jun 24 '20 at 07:12

0 Answers0