Gulp task - Error

Asked

Viewed 301 times

0

I’ve been using Gulp for some time, to minify css files for Less, but now I wanted to use Gulp tb for js files and I’m not getting it, giving the following error. NOTE: Use of 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']); 
 

1 answer

0


You need to add the package gulp-uglify. If you 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

  • Thank you very much man, it worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.