Skip to content

Instantly share code, notes, and snippets.

@codewithpassion
Created July 2, 2016 20:32
Show Gist options
  • Save codewithpassion/8dc5a98e10df262bf6162938ade3ddb0 to your computer and use it in GitHub Desktop.
Save codewithpassion/8dc5a98e10df262bf6162938ade3ddb0 to your computer and use it in GitHub Desktop.
NodeJS require
#!/usr/bin/env node
// To eliminate hard coding paths for require, we are modifying the NODE_PATH to include our lib folder
var oldpath = '';
if( process.env[ 'NODE_PATH' ] !== undefined )
{
oldpath = process.env[ 'NODE_PATH' ];
}
// Append modules directory to path
process.env['NODE_PATH'] = __dirname + '/:' + __dirname + "/src/:" + oldpath;
require('module').Module._initPaths();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment