Currently, if you install a node module using npm install -g, you aren't able to require it after install unless you add the global node_modules folder ($LOCALBASE/lib/node_modules) to NODE_PATH. This behavior seems wrong to me. Here's a patch that adds the global node_modules directory to the default require paths, which makes it so that you can require globally installed node modules without modifying NODE_PATH.
Tested on i386. OKs? Jeremy Index: Makefile =================================================================== RCS file: /cvs/ports/www/node/Makefile,v retrieving revision 1.22 diff -u -p -r1.22 Makefile --- Makefile 21 Dec 2011 09:56:54 -0000 1.22 +++ Makefile 4 Jan 2012 17:11:09 -0000 @@ -11,6 +11,7 @@ COMMENT= V8 JavaScript for clients and s NODE_VERSION= v0.6.6 DISTNAME= node-${NODE_VERSION} PKGNAME= ${DISTNAME:S/v//g} +REVISION= 0 CATEGORIES= www devel @@ -52,5 +53,6 @@ NO_CCACHE= Yes pre-configure: @# Bad practice, but prevents a whole stack of patches. ln -sf ${LOCALBASE}/bin/python${MODPY_VERSION} ${WRKDIR}/bin/python + ${SUBST_CMD} ${WRKDIST}/lib/module.js .include <bsd.port.mk> Index: patches/patch-lib_module_js =================================================================== RCS file: patches/patch-lib_module_js diff -N patches/patch-lib_module_js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-lib_module_js 4 Jan 2012 17:09:02 -0000 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- lib/module.js.orig Wed Jan 4 09:06:46 2012 ++++ lib/module.js Wed Jan 4 09:08:58 2012 +@@ -473,6 +473,8 @@ Module.runMain = function() { + Module._initPaths = function() { + var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')]; + ++ paths.unshift(path.resolve('${TRUEPREFIX}', 'lib', 'node_modules')); ++ + if (process.env['HOME']) { + paths.unshift(path.resolve(process.env['HOME'], '.node_libraries')); + paths.unshift(path.resolve(process.env['HOME'], '.node_modules'));