Here i am creating application to compress a javascript file
Steps i made,
Error : Cannot find module 'uglify-js'
Server.js
var UglifyJS = require('uglify-js');
var fs = require('fs');
var result = UglifyJS.minify('site.js', {
    mangle: true,
    compress: {
        sequences: true,
        dead_code: true,
        conditionals: true,
        booleans: true,
        unused: true,
        if_return: true,
        join_vars: true,
        drop_console: true
    }
});
fs.writeFileSync('site.min.js', result.code);
Installed 'uglify-js modules' in
C:\Users\carunraj\AppData\Roaming\npm\node_modules\uglify-js
Server.js in
C:\Program Files\nodejs
Can any one help?
You installed uglify globally, it won't be "visible" to your package. You want to run npm install uglify-js (without the -g) inside the directory/package where your script is located.
If you're keeping track of dependencies in a package.json (you should be!), npm install --save uglify-js will automatically add it there for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With