How To Install NodeJS with FabricJS on Debian Squeeze

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.

How to install NodeJS on Debian Squeeze
Install NodeJS with FabricJS on Linux 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


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:

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

Set to installation directory

Install dependencies

Install Git core

Install NodeJS

Get the NodeJS codebase

Switch to the node directory

Check NodeJS Version

You can check what the current version of NodeJS is at:
Within Linux, you can also see a list of available versions of NodeJS with:

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.

Configure NodeJS

Make and Install NodeJS

You’ll see a LOT of output in the console here – that’s expected

Verify NodeJS and npm Installation

To verify that the install worked correctly, the following commands should output the version of NodeJS and npm

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

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

Install Canvas Dependencies

Install Canvas

Test Canvas

Test to see if Canvas installed correctly
To test if Canvas installed correctly, first run NodeJs

If Canvas is installed correctly, the following will be output:

Install FabricJS

Test FabricJS

Test to see if FabricJS installed correctly
To test if FabricJS installed correctly, first run NodeJs

If FabricJS is installed correctly, the following will be output:

Install Forever

Test Forever

Test to see if Forever installed correctly, run:

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.

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.

List the Versions of Installed NodeJS (npm) Packages