Node on WebFaction

Trials and tribulations…

Scaffolding

  1. Create another site/app/domain: https://my.webfaction.com/new-website. I love WF’s panel!
  2. Installer scaffolds:
    1. hello-world.js — which we will replace.
    2. ./bin/node: Node’s binary, which we can upgrade manually.
    3. ./bin/{start,stop}: scripts; we will want to edit the start script.
    4. ./bin/npm: symlink to NPM installed in ./lib/node_modules/npm/.
    5. ./run/node.pid: PID file used by the start/stop scripts.
  3. NPM packages installed “globally” will end up in ./lib/node_modules/, still private to just this app/site.

Uploading

Shell

  1. For convenience, so can run “npm” and the scripts from an SSH session, I added this to my ~/.bashrc:
    # For running NPM and start/stop scripts in any Node app's base dir:
    export PATH=$PATH:./bin

Rebuilding/compiling

  1. Some packages, such as “leveldown”, need to run node-gyp to compile C/C++ stuff. Running “npm install” fails:
    ...
    > leveldown@0.10.2 install /home/$USER/webapps/$APP/node_modules/level/node_modules/leveldown
    > node-gyp rebuild
    
    gyp ERR! configure error
    gyp ERR! stack Error: Python executable "python" is v2.4.3, which is not supported by gyp.

    Because my default Python is 2.4, though host has versions up to 3.3 available.

  2. WF say to alias python to another version. Not sure they’ll propagate to sub-shells, so I edit ~/.bashrc:
    # node-gyp needs better Python than default 2.4:
    alias python=python2.7

    But, it doesn’t work! Bash’s manpage says:

    Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt.

  3. An easier workaround: reading the “source”, as I often do, found this in /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js, line 25:
    var python = gyp.opts.python || process.env.PYTHON || 'python'

    So just setting an env variable does the trick:

    PYTHON=python2.7 npm install
  4. But now the compiler fails:
    cc1plus: error: unrecognized command line option "-Wno-unused-but-set-variable"

    (Not the first time I’ve had problems building leveldown. Meh.)
    Google finds a ticket easily: https://github.com/rvagg/node-leveldown/issues/33. Says my compiler is too old. Rightly so:

    $ gcc --version
    gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)
    

    Nu.

CoffeeScript



Comments are closed.