I had a hard time getting a build working on my Linux Mint OS so I thought I would document some steps that may assist you when trying to build your own code base for Fabric.js

# update node, use the more current copy
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node

# Install Fabric – Note if errors from this see the OPTIONAL steps
npm install fabric

#OPTIONAL: In case of g++ errors, install
sudo apt-get install build-essential g++

#OPTIONAL: In case you get cairo errors
sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

#If you continue to get errors, I cloned the git repo and then ran sudo npm update:
git clone https://github.com/kangax/fabric.js.git

# Once this is done, try a build (build_all) but mine still failed with this error:
# Built distribution to dist/fabric.js
# Minification failed using uglifyjs with uglifyjs –compress –mangle –output fabric.min.js fabric.js

sudo npm install -g uglify-js

# THen I still had build issues, seems there was a problem with canvas so I ran this:

sudo npm install canvas
# Now the build_all script seems to have issues so I run this instead (based on the GIT notes)

sudo node build.js modules=ALL