require.paths was removed because it could interfere with how modules are cached. Depending on the current value of require.paths, the same string could resolve to a different file at different times.
It was decided that modules should be local and that '../' is only three characters long. If you get it wrong, you'll now it soon enough. I understand where your module comes from but it is a paradigm that was abandonned some time ago in the node community. In node, modules are local, either in your project's directories or in your project's node_modules. Splitting your project into several files is good, but knowing how and where to split can be hard. On Wednesday, 23 April 2014 03:03:53 UTC+2, Karl Tiedt wrote: > > 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] > <javascript:>>wrote: > >> On Apr 22, 2014, at 4:08 AM, Chetan Dhembre >> <[email protected]<javascript:>> >> 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]<javascript:> >> To unsubscribe from this group, send email to >> [email protected] <javascript:> >> 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] <javascript:>. >> 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.
