FAQ
You can put "." in the end of your NODE_PATH variable, in that way all
require(s) will be evaluated from the starting scripts.
After that you can refer all paths from your starting point.

Den onsdagen den 4:e januari 2012 kl. 10:49:36 UTC+1 skrev Peter Sunde:
Consider having some folders that you want to be accessible within your
application without resulting to absolute/relative paths.

Say you have your standard lib setup:
lib/core/strap.js
lib/route/route.js

Say you have your standard views setup:
views/admin/index.js
views/a/deep/link/index.js

You do not want to deal with relative paths, because it will get quite
cumbersome
when deep-linking of folders occurs.

Relative views/admin/index.js
require("../../lib/core/strap.js")

Instead you reference strap.js via:
require("strap");

Kinda like adding folders to require() so that it understands how to deal
with them.

require.paths(["lib/core", "lib/route"]);
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupnodejs @
categoriesnodejs
postedJan 9, '13 at 3:48p
activeJan 9, '13 at 3:48p
posts1
users1
websitenodejs.org
irc#node.js

1 user in discussion

Bernhard Hettman: 1 post

People

Translate

site design / logo © 2022 Grokbase