Gulp task - Error

0

I already use gulp for some time, to minify css files to less, but now I wanted to use gulp tb for the js files and I'm not getting it, it's giving the following error. NOTE: Use Windows

module.js:472
    throw err;
    ^

Error: Cannot find module 'gulp-uglify'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (c:\xampp\htdocs\php\racing4fun\wp-content\themes\racing4fun\gulpfile.js:3:14)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

My gulp is like this

var gulp = require ('gulp');
var less = require('gulp-less');
var uglify = require('gulp-uglify');
var plumber = require('gulp-plumber');


// Utiliza o 'gulp-less', busca tudo que está dentro da pasta less, compila e devolve na pasta 'css', o gulp.src é o caminho do less e o gulp.dest de saída do css.
gulp.task('less', function () {
  gulp.src('./assets/less/style.less')
   .pipe(plumber())
   .pipe(less())
   .pipe(gulp.dest('./dist/css'))
});


// Java Script
gulp.task('default', function() { 
  gulp.src('./assets/js/functions.js')
    .pipe(sourcemaps.init()) 
      .pipe(uglify()) 
    .pipe(gulp.dest('./dist/js'));  
});

// Aqui a task watch fica observando por mudanças na pasta less, ou seja, toda vez que você salva algo no less ele já compila em css :)
gulp.task('watch', function(){
  gulp.watch('./assets/less/style.less', ['less']); 
});



// Deploys, executando apenas 'gulp' no terminal ele irá rodar a task 'less' e a 'watch' que foram // criadas acima.
gulp.task('default',  ['less', 'watch']); 
 
    
asked by anonymous 14.05.2017 / 15:53

1 answer

0

You need to add the gulp-uglify package. If you have already specified this package in the package.json of your project, just use npm install to install the dependencies, otherwise use the command npm install --save-dev gulp-uglify

    
14.05.2017 / 19:39