Various versions of Linux have slightly different methods for installing some packages – NodeJS is one of them. So when I had to setup a Debian Squeeze server with NodeJS I figured I’d write down my success instructions so that I can share it with all of you as well.
This set of instructions will walk through installing NodeJS with npm (Node Package Manager), Canvas, FabricJS, and a few other dependancies and npm packages, such as forever, on Debian Squeeze via command line.

This setup was done on a Sonassi MageStack server.
Distributor ID: Debian
Release: 6.0.10
Codename: squeeze
UPDATE June 3rd, 2015
I found that instead calling node didn’t work for some reason on a clean install. Instead, call nodejs wherever you’d typically call node.
I just used these same instructions for installation on Ubuntu as well. I found that my older instructions for installation of NodeJS on Ubunutu didn’t work on this version.
Distributor ID: Ubuntu
Release: 15.04
Codename: vivid
Setup
Set User
Note: it’s easiest to install while logged in as the root user.
If you are not currently using the root user, you can switch to it with:
1 2 | su root |
You will be prompted to enter your password.
If you are not logged in as the root user, add ‘sudo’ before the commands below.
Check Linux Version
1 | lsb_release -irc |
Set to installation directory
1 2 | cd /usr |
Install dependencies
1 2 | sudo apt-get install python-software-properties python g++ make |
Install Git core
1 2 | apt-get install git-core curl |
Install NodeJS
Get the NodeJS codebase
1 2 | git clone https://github.com/joyent/node.git |
Switch to the node directory
1 2 | cd node |
Check NodeJS Version
You can check what the current version of NodeJS is at:
http://nodejs.org/download/
Within Linux, you can also see a list of available versions of NodeJS with:
1 2 | git tag |
Get the repository for git.
Use the version number that you wish to install – for most installations this will be the most recent stable version found in the step above.
1 2 | git checkout v0.10.32 |
Configure NodeJS
1 2 | ./configure --openssl-libpath=/usr/lib/ssl --without-snapshot |
Make and Install NodeJS
You’ll see a LOT of output in the console here – that’s expected
1 2 3 4 | make make test make install |
Verify NodeJS and npm Installation
To verify that the install worked correctly, the following commands should output the version of NodeJS and npm
1 2 3 | node -v npm -v |
Uninstall NodeJS (OPTIONAL)
If for whatever reason you need to uninstall NodeJS you can do the following
#NOTE: you need to be in the directory of your NodeJS install.
In my case, it is /usr/node
1 2 | make uninstall |
At this point, NodeJS and npm should be installed and ready for use.
Install FabricJS and npm Packages
FabricJS is both a browser and NodeJS library for interacting with the HTML5 canvas. In the browser a user can configure a canvas design. When the design is passed to a NodeJS server, you can use the npm FabricJS, Canvas, and ImageMagick packages to quickly render out images of various sizes and qualities. This next set of instructions will walk through how to setup and test these packages on the server. As for coding all of this fun, that’s for another day.
Set Directory
Change to the node_modules directory
1 2 | cd /usr/local/lib/node_modules |
Install Canvas Dependencies
1 2 | apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ |
Install Canvas
https://www.npmjs.org/package/canvas
1 2 | npm install -g canvas |
Test Canvas
Test to see if Canvas installed correctly
To test if Canvas installed correctly, first run NodeJs
1 2 | node typeof require('canvas') |
If Canvas is installed correctly, the following will be output:
1 2 3 | #'function' #NOTE: Ctrl+C twice will exit NodeJS |
Install FabricJS
https://www.npmjs.org/package/fabric
1 2 | npm install -g fabric |
Test FabricJS
Test to see if FabricJS installed correctly
To test if FabricJS installed correctly, first run NodeJs
1 2 3 | node typeof require('fabric') |
If FabricJS is installed correctly, the following will be output:
1 2 3 | #'object' #NOTE: Ctrl+C twice will exit NodeJS |
Install Forever
https://www.npmjs.org/package/forever
1 2 | npm install forever -g |
Test Forever
Test to see if Forever installed correctly, run:
1 2 | forever |
The forever help information should display,
Helpful Commands
Install specific npm version
When installing an npm package, a specific version can be chosen. This allows you to install what version you’d like, or change from one version to another.
1 2 | install -g fabric@1.1.6 |
Global Flag
When installing a npm package, you can choose to install it locally or globally. The difference is whether you are running your NodeJS application from a specific folder that the local package is installed in, or if you want a NodeJS application to be run from any directory and have access to any npm package.
To install globally, include the -g flag. To install locally, do not include the -g flag.
1 2 | install fabric #local install -g fabric #global |
List the Versions of Installed NodeJS (npm) Packages
1 2 | npm ls |
Resources
http://monicalent.com/blog/2014/06/13/install-node-js-on-debian-squeeze/