I'm trying to access modules but the nesting gets a bit out of hand
require("../../../Folder/Deeper/someFile")
Is there anyway to just use require("Folder/Deeper/somefile")
I've tried setting
require.paths = ['/media/work/Project'];
but that doesn't seem to work and also feels a bit ugly to me.
Are there any alternatives. Is there any way to write a wrapper for this?
Maybe this?
require.paths.unshift( '../../..' );
require("Folder/Deeper/somefile");
http://nodejs.org/api.html says:
require.paths An array of search paths for require(). This array can be modified to add custom paths.
Example: add a new path to the beginning of the search list
require.paths.unshift('/usr/local/node');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With