Thank you, this was very helpful. Putting a plain .js file in that 
directory distinguishes it sufficiently from other npm packages. However, 
instead of putting the actual component file in there I opt to add a new 
file  ./node_modules/component.js containing the following single statement 
in it to load the component:

exports = module.exports = require('../path/to/component.js');


I know that some may facepalm, but I really like to distinguish own app 
code from npm dependencies. Plain .js files are indeed both 
programmatically (npm commands) and visually sufficiently different from 
package folders.

Thank you everyone for your suggestions!


On Saturday, February 9, 2013 3:02:12 AM UTC+1, Isaac Schlueter wrote:
>
> I don't think it's a hack.  Rather elegant, really: 
>
>     mkdir node_modules 
>     mv path/to/component.js node_modules/component.js 
>     node -pe "require('component') // voila" 
>
> You could also make it a full-fledged package (jus a matter of adding 
> one extra file package.json, which npm can do for you, though a README 
> and LICENSE are strongly encouraged as well), and then list it as a 
> dependency.  That's the more "traditional" way that people handle 
> dependencies like this.  npm ignores anything in node_modules that 
> isn't a package, so it should be fine just leaving it there, 
> otherwise. 
>
>
> On Fri, Feb 8, 2013 at 5:24 PM, Geerten van Meel 
> <klov...@gmail.com<javascript:>> 
> wrote: 
> > Hi, 
> > 
> > I am working on an app and would like to access a component of my app 
> simply 
> > using require('component') instead of require('./component') or worse 
> > require('./path/to/component.js'). I know that there are ways to achieve 
> > this by doing some hack regarding the node_modules folder, but I would 
> like 
> > to ask whether there is a simple, elegant way to achieve this result 
> (and 
> > not interfere with npm when deploying)? 
> > 
> > To summarize: 
> > 
> >  - I would like to include an app component using require('component') 
> > instead of require('./path/to/component.js'). 
> > 
> >  - The components location should ideally be somewhere out of 
> node_modules 
> > in order to not mess with npm. 
> > 
> >  - NODE_PATH, thus process arguments should not be provided via the 
> command 
> > line. 
> > 
> > Thank you for your time and suggestions! 
> > 
> > Geerten 
> > 
> > -- 
> > -- 
> > 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 nod...@googlegroups.com<javascript:> 
> > To unsubscribe from this group, send email to 
> > nodejs+un...@googlegroups.com <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 nodejs+un...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to