I was just wondering the same thing... if your module is published in NPM or not... unless someone forcibly modifies your modules directory structure then relative paths INSIDE your module should be perfectly fine....
-Karl Tiedt On Tue, Apr 22, 2014 at 8:00 PM, // ravi <[email protected]> wrote: > On Apr 22, 2014, at 4:08 AM, Chetan Dhembre <[email protected]> > wrote: > > I recently create module <https://www.npmjs.org/package/local-require>. > Which help in avoiding mess of relative path while including local > modules.I post module link and ask suggestion on #node.js irc center many > people think it is basically wrong to have nested directory structure ( i > also know it is dirty). > > > > I am puzzled by why anyone would think nested directory structure is wrong > or dirty. Did they explain why this is a bad idea? I’d say quite the > opposite (for the same reasons why hierarchical directories exist in the > operating system :-)). > > > So i was searching around in some big project in node.js . I come across > ghost > <https://github.com/TryGhost/Ghost>which is fairly large node.js project. > I end up looking their directory structure which is more or less nested .. > i find following code > > var fs = require('fs'), >> config = require('../../server/config') >> > > which requiring local module using relative path and there is no second > thought is this is error prone. > > My question how does other large project manage code .. because there so > many small piece code which are closely related to project so can not > publish on npm and creating that number or private repo is not financially > feasible ( talking about github) > > > > I use NODE_PATH (in Unix, not sure what the equivalent is in Windows) to > remove the “.." parts in the require() path. There used to be a way to > specify this inline in the code, using require.paths (IIRC), which was > really nice, but for some reason (that I now forget) that was removed. > Something like this: > > ====== > > /home/ravi/code/projectX/app.js: > > var fs = require(‘fs’), > config = require(‘server/config’); > > $ daemon ….. —env=“NODE_PATH=/home/ravi/code/projectX/server:…other local > module paths…” /home/ravi/code/projectX/app.js > > ====== > > This of course still uses a relative path (‘server/config’) but that I > consider a feature that exposes the internal hierarchy of my code. > > Note: I am using ‘daemon’ to daemonise app.js (so it runs long after I > have left the shell). There are other ways to do that and you may not need > that at all, and might instead prefer writing a shell wrapper that sets > NODE_PATH and then runs app.js. > > Cheers, > > —ravi > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
