Trials and tribulations…
Scaffolding
- Create another site/app/domain: https://my.webfaction.com/new-website. I love WF’s panel!
- Installer scaffolds:
- hello-world.js — which we will replace.
- ./bin/node: Node’s binary, which we can upgrade manually.
- ./bin/{start,stop}: scripts; we will want to edit the start script.
- ./bin/npm: symlink to NPM installed in ./lib/node_modules/npm/.
- ./run/node.pid: PID file used by the start/stop scripts.
- NPM packages installed “globally” will end up in ./lib/node_modules/, still private to just this app/site.
Uploading
…
Shell
- 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
- 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.
- 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.
- 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
- 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
…