Installing uglyfi-js and node on Ubuntu 12.10

The e-Classifieds ® Corporate edition uses lots of JavaScript code, so to help speed things up we compress the code. Previously this has been done using JavaScript::Minifier::XS from CPAN, but all the cool kids are using UglifyJS. So I thought I would see how it compared.

UglifyJS is a NodeJS package. I’m not a great fan of having to install an entirely new suite of tools just to test one thing, but it doesn’t seem like NodeJS is going away anytime soon, so I added it. To minimize problems I started on my own desktop running Ubuntu (Kubuntu), but I immediately ran into this error:


npm ERR! error installing uglify-js@2.2.3

npm ERR! Error: No compatible version found: source-map@’>=0.1.7- <0.2.0-‘
npm ERR! Valid install targets:
npm ERR! [“0.0.0″,”0.1.0″,”0.1.1″,”0.1.2″,”0.1.3″]
npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:488:10)
npm ERR! at next_ (/usr/share/npm/lib/cache.js:438:17)
npm ERR! at next (/usr/share/npm/lib/cache.js:415:44)
npm ERR! at /usr/share/npm/lib/cache.js:408:5
npm ERR! at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7)
npm ERR! at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7)

Which is a rather long message to say that you need to upgrade NodeJS. The problem is that I was running the latest version of NodeJS that Ubuntu distributes. Fortunately when you search launchpad you can usually find someone who has added the latest version of whatever you are looking for. And sure enough there is a PPA for the latest version of NodeJS. You can install it using the following commands:


sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

Once you have NodeJS updated you can then get UglifyJS installed easily:

npm install uglify-js

Now to see how small this makes the JavaScript on our e-Classifieds (r) Corporate edition. If it is good enough we might add nodeJS to the servers for general use.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: