node sqlite3 module fails to install

The OpenShift forums have been retired.
You can still read and search them, but for help, please post a question on Stack Overflow.

Hi,

I'm trying to deploy a very simple node.js test app using an sqlite3 database. However, the node-sqlite3 module fails to install. The error messages are slighly cryptic, but I suspect it to be a permission issue, the error message in question appears to be:

gyp ERR! rebuild error Error: EXDEV, link '/usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp/gyptest.pyc'

$ cd /tmp
$ mkdir tmp
$ npm --verbose install sqlite3
[...]
> sqlite3@2.1.5 install /tmp/tmp/node_modules/sqlite3
> node-gyp rebuild
[...]
gyp verb legacy copying "legacy" gyp configuration files for version 0.6.20
gyp verb legacy using "legacy" dir /usr/lib/node_modules/npm/node_modules/node-gyp/legacy
gyp verb legacy copying to "dev" dir /var/lib/openshift/513a378e4382ec7cab00000e/.node-gyp/0.6.20
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/common.gypi
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/addon.gypi
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp_addon
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp/gyptest.pyc
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp/codereview.settings
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp/gyp_dummy.c
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp/pylintrc
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp/PRESUBMIT.pyo
gyp verb legacy reading entry: /usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp/gyptest.pyo
gyp WARN install got an error, rolling back install
gyp verb command remove [ '0.6.20' ]
gyp verb remove using node-gyp dir: /var/lib/openshift/513a378e4382ec7cab00000e/.node-gyp
gyp verb remove removing target version: 0.6.20
gyp verb remove removing development files for version: 0.6.20
gyp ERR! rebuild error Error: EXDEV, link '/usr/lib/node_modules/npm/node_modules/node-gyp/legacy/tools/gyp/gyptest.pyc'
gyp ERR! not ok 
npm info sqlite3@2.1.5 Failed to exec install script
npm info /tmp/tmp/node_modules/sqlite3 unbuild
npm verb from cache /tmp/tmp/node_modules/sqlite3/package.json
npm info preuninstall sqlite3@2.1.5
npm info uninstall sqlite3@2.1.5
npm verb true,/tmp/tmp/node_modules,/tmp/tmp/node_modules unbuild sqlite3@2.1.5
npm info postuninstall sqlite3@2.1.5
npm ERR! sqlite3@2.1.5 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the sqlite3@2.1.5 install script.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls sqlite3
npm ERR! There is likely additional logging output above.
 
npm ERR! System Linux 2.6.32-279.19.1.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "--verbose" "install" "sqlite3"
npm ERR! cwd /tmp/tmp
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
npm ERR! code ELIFECYCLE
npm ERR! message sqlite3@2.1.5 install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 1
npm verb exit [ 1, true ]
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /tmp/tmp/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 1

Any ideas?

-Marius

PS. I'm using the FreeShift plan if that makes a difference

You'll need to use package.json to add your dependencies. On git push, npm is used to install it on the gear in the correct node_modules/ locations. Doing it by hand on the gear will throw errors.

Update: Spoke too soon, it also failed with the same errors.

Yes, I know - I redid it manually before posting to make it easier to reproduce.

@marius, think its an issue with the version of node-gyp installed on OpenShift (the version is pretty
old since the installed node version is v0.6). Old versions of node-gyp tried to create hard links
to ~/.node-gyp and it will fail on OpenShift since the link would be span different file systems.

Couple of options -- specify a version of sqlite3 that works -- tried and found that sqlite3@2.1.1 seems
to work fine (it is old though). The other alternative is to try and install v0.8 or v0.9 version of node
(see: https://github.com/ramr/nodejs-custom-version-openshift for more details).

HTH

Thanks @ramr - that makes a lot of sense.

@nduong: Are there plans to officially support node 0.8 (or a custom node version) on OpenShift?