WebFaction
Community site: login faq

Hi,

I am trying to run node-canvas (https://github.com/Automattic/node-canvas/) on webfaction.

On my local centos 6.6 environment I simply followed the instruction at https://github.com/Automattic/node-canvas/wiki/Installation---Fedora and installed required dependencies via yum. However, obviously I cannot run yum on webfaction, so I tried to build dependencies manually in my home directory. Since the package requires cairo and pango, I followed this post https://community.webfaction.com/questions/11481/how-to-install-pango-and-cairo-pangocairo-for-python and successfully installed them.

Then I built giflib (http://sourceforge.net/projects/giflib/) to satisfy the other dependency, configuring it with prefix=$HOME and then running make and make install without errors.

However, when running /bin/npm install within my node app directory, I get the following errors when npm tries to build node-canvas package.

$ bin/npm install
canvas@1.1.6 install
node-gyp rebuild
make: Entering directory
> SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
> SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node: Finished
> COPY Release/canvas-postbuild.node
> CXX(target) Release/obj.target/canvas/src/Canvas.o
> In file included from ../src/Canvas.cc:8:
> ../src/PNG.h: In function 'cairo_status_t canvas_write_png(cairo_surface_t*, voi
> d (*)(png_struct*, png_byte*, png_size_t), void*)':
> ../src/PNG.h:165: warning: case label value is less than minimum value for type
> CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
> CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
> In file included from ../src/CanvasPattern.cc:9:
> ../src/Image.h:19:21: warning: gif_lib.h: No such file or directory
> CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
> In file included from ../src/CanvasRenderingContext2d.cc:15:
> ../src/Image.h:19:21: warning: gif_lib.h: No such file or directory
> CXX(target) Release/obj.target/canvas/src/color.o
> CXX(target) Release/obj.target/canvas/src/Image.o
> In file included from ../src/Image.cc:8:
> ../src/Image.h:19:21: warning: gif_lib.h: No such file or directory
> ../src/Image.cc:443: error: 'GifFileType' was not declared in this scope
> ../src/Image.cc:443: error: 'gif' was not declared in this scope
> ../src/Image.cc:443: error: expected primary-expression before 'int'
> ../src/Image.cc:443: error: initializer expression list treated as compound expr
> ession
> ../src/Image.cc:443: error: expected ',' or ';' before '{' token
> make: *** [Release/obj.target/canvas/src/Image.o] Error 1
> make: Leaving directory `/home/slideeffect/webapps/thenewroom/node_modules/canva
> s/build'
> gyp ERR! build error
> gyp ERR! stack Error: `make` failed with exit code: 2
> gyp ERR! stack     at ChildProcess.onExit (/home/slideeffect/webapps/thenewroom/
> lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
> gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
> gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:
> 12)
> gyp ERR! System Linux 2.6.32-431.29.2.el6.x86_64
> gyp ERR! command "node" "/home/slideeffect/webapps/thenewroom/lib/node_modules/n
> pm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
> gyp ERR! cwd /home/slideeffect/webapps/thenewroom/node_modules/canvas
> gyp ERR! node -v v0.10.31
> gyp ERR! node-gyp -v v1.0.1
> gyp ERR! not ok
> npm ERR! canvas@1.1.6 install: `node-gyp rebuild`
> npm ERR! Exit status 1
> npm ERR! Failed at the canvas@1.1.6 install script.

Has anyone successfully installed node-canvas on webfaction? Any idea what could be wrong?

asked 22 Jun '15, 19:44

slideeffect
2114
accept rate: 100%


Hi Sean,

Yes, I had exported CPPFLAGS etc. as part of building cairo and pango.

What I was missing was setting CXXFLAGS to force npm to look into my local include directory.

Invoking npm as follows worked:

CXXFLAGS=-I/$HOME/include LDFLAGS=-L/$HOME/lib bin/npm install

Thanks for pointing me in the right direction.

permanent link

answered 23 Jun '15, 22:42

slideeffect
2114
accept rate: 100%

It looks like the build can't locate your giflib headers.

Have your tried setting CPPFLAGS and the other environment variables described in our general build docs?

permanent link

answered 22 Jun '15, 23:11

seanf
12.2k31836
accept rate: 37%

edited 22 Jun '15, 23:11

mkdir -p $HOME/src $HOME/tmp
export TMPDIR="$HOME/tmp"
export PATH="$HOME/bin:$PATH"
export C_INCLUDE_PATH="$HOME/include:$C_INCLUDE_PATH"
export LIBRARY_PATH="$HOME/lib:$LIBRARY_PATH"
export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"
export CPPFLAGS="-I$HOME/include $CPPFLAGS"
export LDFLAGS="-L$HOME/lib $LDFLAGS"
export PKG_CONFIG_PATH="$HOME/lib/pkgconfig"

# =========================================
# pixman 0.24.4
# =========================================
cd $HOME/src
wget 'http://mirror.ryansanden.com/xfce-4.8/pixman-0.24.4.tar.gz'
tar -xzf pixman-0.24.4.tar.gz
cd pixman-0.24.4
./configure --prefix=$HOME
make
make install

# =========================================
# cairo 1.12.0
# =========================================
cd $HOME/src
wget 'http://mirror.ryansanden.com/xfce-4.8/cairo-1.12.0.tar.gz'
tar -xzf cairo-1.12.0.tar.gz
cd cairo-1.12.0
./configure --prefix=$HOME
make    # 2m
make install

# =========================================
# libffi 3.0.11
# =========================================
cd $HOME/src
wget 'http://mirror.ryansanden.com/xfce-4.8/libffi-3.0.11.tar.gz'
tar -xzf libffi-3.0.11.tar.gz
cd libffi-3.0.11
./configure --prefix=$HOME
make
make install

# =========================================
# Glib 2.31.22
# =========================================
cd $HOME/src
wget 'http://mirror.ryansanden.com/xfce-4.8/glib-2.31.22.tar.xz'
tar -xJf glib-2.31.22.tar.xz
cd glib-2.31.22
PYTHON=${PYTHON} ./configure --prefix=$HOME
make    # 2.5m
make install

# =========================================
# pango 1.30.0
# =========================================
cd $HOME/src
wget 'http://mirror.ryansanden.com/xfce-4.8/pango-1.30.0.tar.xz'
tar -xJf pango-1.30.0.tar.xz
cd pango-1.30.0
./configure --prefix=$HOME --sysconfdir=$HOME/etc
make    # 22s
make install

CXXFLAGS=-I/$HOME/include LDFLAGS=-L/$HOME/lib bin/npm install
permanent link

answered 31 Oct '15, 16:00

ryanouyang
11
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×67
×9
×3
×2
×2

question asked: 22 Jun '15, 19:44

question was seen: 3,966 times

last updated: 31 Oct '15, 16:00

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM