Here i am creating application to compress a javascript file
Steps i made,
- Installed nodeJS in my local machine
- checked node and npm is working
- Installed "uglify-js" by "npm install uglify-js -g" and installed
- When i try to run by "node server.js" in command prompt throwing error
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?
server.jsfile instead? Might make a difference.