In RequireJS I am able to remap paths using a config file, e.g.:
require.config({
paths: {
foo: 'lib/foo/foo'
}
})
I can then use foo like so:
require(['foo'], function(foo) {...})
In node.js I can similarly require local files, e.g:
var foo = require('../lib/foo/foo.js')
(In this example, foo.js is a file I have written that is not available via npm.)
Is it possible to remap 'foo' to '/lib/foo/foo.js' relative to some base directory in node.js so I don't have to use relative paths?
You can't "remap" things in Node -- at least not natively, probably there are packages for this purpose.
However, you are able to put your code in the node_modules directory and require it.
But be sure to put your folder name in the bundledDependencies section of the package.json file. See here for more detailed info.