On Apr 14, 2015, at 9:21 PM, Alexander Praetorius <[email protected]> wrote:
>
> I want to avoid "relative require" (e.g. require('../../foobar');)
> I get that by stuffing everything into a "node_modules" folder.
>
With the confession that I have not been following this thread and have not
taken the trouble to understand the full discussion, I want to add one comment.
I too have tried to avoid relative paths in my code. At the same time, I do not
want to stuff all my libraries and modules into “node_modules” in the app root
directory. My solution is/was to use NODE_PATH in a manner similar to how
library paths have been used traditionally for years on Unix. Works perfectly
for me:
* External modules are in /X/Y/node/lib/……… (installed using ‘npm install -g’)
* My system wide modules are in /A/B/lib/………
* App level modules are in /A/B/app1/lib/……
* App config is in /A/B/app1/config/……
NODE_PATH is set by a wrapper to:
"/A/B/lib:/A/B/app1/lib:/A/B/app1/config:/X/Y/node/lib”. Would have made my
life easier if require.path had not been removed, but such is life.
—ravi
> I want my project's internal modules, which are not published (at least yet)
> and only something custom to my project, to be available in the same way the
> installed modules are.
>
> So I have a "node_modules" folder at the project root, where all the "npm
> install"ed stuff goes in.
> I have another in "SOURCE/node_modules" which I maintain manually.
> If I ever feel like, I rename that internal module from "_foobar" to "foobar"
> and publish it and "npm install" it.
>
> The advantage of the "_naming" is, that I can immediately see which modules
> are "npm installed" and which are actually local modules, so I maintain them
> myself and I know where to look for.
>
> Everything that I have to manually, for example:
>
> [SOURCE/node_modules/_config.js]
> module.exports = { pkg: require('../../package.json') };
>
> I require in "_config.js" by convention, so I can access it in the rest of my
> app, by "require('_config').pkg" without further need for relative require
> statements.
>
>
>
> On 14 April 2015 at 16:17, Aria Stewart <[email protected]> wrote:
>
>
> On Tuesday, April 14, 2015 at 10:05:24 AM UTC-4, serapath wrote:
>
> ├── package.json
> ├── readme.MD
> └── SOURCE
> ├── index.js
> └── node_modules
> ├── _client
> │ └── index.js
> ├── _config.js
> ├── _server
> │ └── index.js
> └── _shared
> └── index.js
>
>
> Oh my, that is definitely weird!
>
> I think once you get to _naming things you've gone off the rails somewhere.
>
> What's the actual problem you're trying to solve?
>
> Aria
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/74798259-4C8D-4F2B-B9FC-9EDA785F11DA%40g8o.net.
For more options, visit https://groups.google.com/d/optout.