I have a question about how to install Uglify or Uglify2 on Debian. I'm also wondering whether I have to install Node.js as well.

My main goal of asking this question is to minify all my CSS and .js files and gzip/compress them so that the page load on my website gets faster for visitors.

I was looking over the net for a step by step tutorial on how to do that, but got nothing handy so far.

Does any one know how to do that?

2 Answers 2


You install uglify-js with npm which comes from Node.js

Install the npm package (which depends on nodejs)

apt-get install npm

Install uglifyjs

npm install --global uglifyjs

Now you have uglify-js

$ uglifyjs --version
uglify-js 2.4.13

Alternatively you can download the Node.js linux binaries from the download page.

wget https://nodejs.org/dist/v4.4.5/node-v4.4.5-linux-x64.tar.gz

Then extract Node to somewhere of your choosing

tar -C /opt -xvzf node-v4.4.5-linux-x64.tar.gz
export PATH="$PATH:/opt/node-v4.4.5-linux-x86/bin"

Or install Node system-wide

tar -C /usr/local --strip-components 1 -xvzf node-v4.4.5-linux-x64.tar.gz

clone the repository

mkdir -p /where/you/wanna/put/it
cd /where/you/wanna/put/it
git clone git://github.com/mishoo/UglifyJS.git

make the module available to Node

mkdir -p ~/.node_libraries/
cd ~/.node_libraries/
ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js

and if you want the CLI script too:

mkdir -p ~/bin
cd ~/bin
ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs

(then add ~/bin to your $PATH if it's not there already)

  • Thanks a lot for the great explanation. I wish I could mark your answer,too. Thanks again. Jun 4, 2014 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .