[nodejs] basic dependency question

2013-01-14 Thread Thiago Souza
Hello all, I've got a basic dependency question. Consider the following dependencies: (module A) --> (module B) (module A) --> (module C) (module B) --> (module C) So, C is a shared dependency between A and B, but A also depends on B. My question is

Re: [nodejs] basic dependency question

2013-01-14 Thread Rick Waldron
No, they do not share C, they will use their own version of C, which is whatever is specified in the package.json file for that module. Rick On Mon, Jan 14, 2013 at 2:45 PM, Thiago Souza wrote: > Hello all, > > I've got a basic dependency question. Consider the following > dependencies:

Re: [nodejs] basic dependency question

2013-01-14 Thread Dan Milon
Dependencies (aka `require`s) are resolved synchronously. So the flow is: A --> B --> C A --> C Also modules are cached. [1] ie, they are not loaded twice. A and B "see" the same version of C. [1] http://nodejs.org/docs/latest/api/modules.html#modules_caching Hope this helps, danmilon. On 01/1

Re: [nodejs] basic dependency question

2013-01-14 Thread Angel Java Lopez
Well, it could be that B uses C-0.0.1 (declared in its package.json), and A uses C-0.0.2 So A --> B --> C-0.0.1 A --> C-0.0.2 node_modules/A/node_modules/B/node_modules/C <-- C-0.0.1 here node_modules/A/node_modules/C <-- C-0.0.2 here On Mon, Jan 14, 2013 at 5:49 PM, Dan Milon wrote: > Depen

Re: [nodejs] basic dependency question

2013-01-14 Thread Dan Milon
Right. I was referring to modules of the same package. On 01/14/2013 11:02 PM, Angel Java Lopez wrote: > Well, it could be that B uses C-0.0.1 (declared in its > package.json), and A uses C-0.0.2 > > So > > A --> B --> C-0.0.1 A --> C-0.0.2 > > node_modules/A/node_modules/B/node_modules/C <--

Re: [nodejs] basic dependency question

2013-01-14 Thread Rick Waldron
On Mon, Jan 14, 2013 at 4:02 PM, Angel Java Lopez wrote: > Well, it could be that B uses C-0.0.1 (declared in its package.json), and > A uses C-0.0.2 > > So > > A --> B --> C-0.0.1 > A --> C-0.0.2 > > node_modules/A/node_modules/B/node_modules/C <-- C-0.0.1 here > node_modules/A/node_modules/C <--

Re: [nodejs] basic dependency question

2013-01-14 Thread Isaac Schlueter
Dan, Rick, and Angel are all correct, but it depends somewhat on the situation. See https://npmjs.org/doc/folders.html for a thorough explanation of how npm does this, and http://api.nodejs.org/modules.html for a thorough explanation of how Node resolves require() calls to real files. Note that n