Dmitry Leskov
 

How To Run UglifyJS on Windows Using node.js

A few days ago, I’ve been looking for a JavaScript minifier and wondered what the jQuery team may be using today. Turned out, they have abandoned Google Closure in favor of UglifyJS – a JavaScript parser/compressor/beautifier created by Mihai Bazon. UglifyJS is written in JavaScript and therefore should run on any JavaScript engine, but its “native” one is node.js, which is only available for Unix-like systems, including Linux, BSD, and Mac, but not for Windows. Or so I thought.

Fact is, Microsoft is now helping port node.js to Windows, and there is already a Windows build available, very elegant – just one 10MB file called node.exe :) – albeit unstable. Anyway, as of version 0.5.4 it seems to be capable of running UglifyJS. You just need to set the NODE_PATH environment variable accordingly:

set NODE_PATH=C:\EXE\UglifyJS
C:\EXE\node C:\EXE\UglifyJS\bin\uglifyjs options script-file

(Of course you should correct the pathnames to point to the locations of UglifyJS and node.exe on your system.)

« | »

Talkback

  1. wencha
    02-Sep-2011
    2:29 am
    1

    Can you please specify how to do it?? I’ve downloaded the last version of UglifyJS from https://github.com/mishoo/UglifyJS (zip v1.0.7). Also node.exe from http://nodejs.org/#download. I have the two things now what?? Please help!

  2. Dmitry Leskov
    02-Sep-2011
    12:16 pm
    2

    Unpack the zip file and edit the paths in the commands above in accordance with the location of node.exe and UglifyJS on your system. You may put these commands into a .bat file.

    I have node.exe in C:\EXE and UglifyJS in C:\EXE\UglifyJS.

* Copy This Password *

* Type Or Paste Password Here *