Contextify module build fails - missing Release directory issue

I’m trying to package my Node.js application for deployment on a production server that doesn’t have npm installed. I’ve used npm to download all required dependencies into a local node_modules directory based on my package.json configuration.

Everything seems to work fine during the setup process, but when I try to execute the application on the target server, I get an error saying Cannot find module '../build/Release/contextify'.

Looking into this issue, I found that the contextify module at node_modules/.npm/contextify/0.0.4/package/lib/contextify.js is trying to load this specific file, but the node_modules/.npm/contextify/0.0.4/package/build folder doesn’t contain any Release subdirectory.

I thought maybe the module wasn’t properly compiled, so I went back to my development environment and executed npm install again. The installation process seemed to work and showed contextify being built:

$ npm install

> [email protected] preinstall /my/project/path/node_modules/contextify
> node-waf clean || true; node-waf configure build

'clean' finished successfully (0.012s)
Setting srcdir to: /my/project/path/node_modules/.npm/contextify/0.0.4/package
Setting blddir to: /my/project/path/node_modules/.npm/contextify/0.0.4/package/build
Checking for program g++ or c++: /usr/bin/g++
Checking for program cpp: /usr/bin/cpp
Checking for program ar: /usr/bin/ar
Checking for program ranlib: /usr/bin/ranlib
Checking for g++: ok
Checking for node path: not found
Checking for node prefix: ok /usr/local/Cellar/node/0.4.5
'configure' finished successfully (0.041s)
Waf: Entering directory `/my/project/path/node_modules/.npm/contextify/0.0.4/package/build`
[1/2] cxx: src/contextify.cc -> build/default/src/contextify_1.o
[2/2] cxx_link: build/default/src/contextify_1.o -> build/default/contextify.node
Waf: Leaving directory `/my/project/path/node_modules/.npm/contextify/0.0.4/package/build`
'build' finished successfully (0.351s)

However, even after this apparently successful build process, the package/build directory still lacks the Release folder that the module is looking for.

Is this build failure related to the “node path: not found” message I’m seeing during configuration? I attempted setting export NODE_PATH but that didn’t resolve the issue. What could be causing contextify to not build properly, and how can I fix this deployment problem?

sounds like node-waf is putting stuff in build/default/ but contextify is looking for build/Release/. You could try making a symlink like this: ln -s default Release. I ran into this with older mods too that have different expectations.

This is a common issue with old Node.js modules that still use node-waf instead of the newer node-gyp build system. I’ve run into the same thing with contextify on an older app. The build looks successful, but it puts the compiled binary in build/default/ while the module loader expects it in build/Release/. That’s just how node-waf and node-gyp handle directory structures differently. Since you’re deploying to a server without npm, build it in an environment that matches your target server as closely as possible. After building locally, just copy build/default/contextify.node to build/Release/contextify.node in the contextify package directory before you package everything for deployment. Better yet, if you can swing it, upgrade to a newer version of whatever library uses contextify. Most modern alternatives have ditched this problematic module entirely.

Had the same issue deploying an old Node app last year. Contextify is ancient - built for Node 0.4-0.6 using node-waf instead of node-gyp. Modern Node versions just don’t work with it.

I fixed it by switching to jsdom 0.2.14 or earlier (uses contextify), then upgrading to newer jsdom that ditches contextify completely. If you’re stuck with contextify, you’ll need to rebuild it manually on your server or find a different solution.

Or just containerize with Docker so you can build everything in the same environment it’ll run in. Skips the whole missing build tools headache.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.