Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module 'gulp-uglifyjs' with "gulp watch

Tags:

gulp

I´m in my project folder on my terminal, and:

if I extecute:

     gulp -v

I get:

[15:47:15] CLI version 3.9.0
[15:47:15] Local version 3.9.0

if I excute:

 gulp watch

I get:

Error: Cannot find module 'gulp-uglifyjs'
   at Function.Module._resolveFilename (module.js:338:15)
   at Function.Module._load (module.js:289:25)
   at Module.require (module.js:366:17)
   at require (module.js:385:17)
   at Object.<anonymous>    (/Applications/XAMPP/xamppfiles/htdocs/last/gulpfile.js:3:14)
   at Module._compile (module.js:425:26)
   at Object.Module._extensions..js (module.js:432:10)
   at Module.load (module.js:356:32)
   at Function.Module._load (module.js:313:12)
   at Module.require (module.js:366:17)
   at require (module.js:385:17)

Then, I search in the gulpfile.js 3:14 and I see this:

var uglify = require('gulp-uglifyjs');

I was read about this, a lot people say "oh, do npm install", I do, and after make npm -v I get this:

 3.3.12

I was trying with a lot commands, but I dont know what happen. Maybe gulpfile.js?

Maybe I forgot a dependencie?

like image 631
BigBugCreator Avatar asked Feb 21 '26 10:02

BigBugCreator


2 Answers

Maybe I forgot a dependencie?

Yes maybe local installation will resolve you problem. Run next command in you project:

npm install --save-dev gulp-uglify
like image 98
Ivan M Avatar answered Feb 24 '26 15:02

Ivan M


Try to replace require('gulp-uglifyjs'); with require('gulp-uglify');

see also https://www.npmjs.com/package/gulp-uglify

like image 40
Sergio Ivanuzzo Avatar answered Feb 24 '26 14:02

Sergio Ivanuzzo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!