There is no absolute best way to do that.

require caches the content of the file after the first access. Calls to
require after the first one will just return the cached content, and the
file will not be parsed again. Use this approach if you expect that the
content of the file never change during the execution time of your
application.

If you read and parse the file manually you are in charge of controlling if
you want to reload the content every time you access it or if you want to
cache its content. In addition, programmatically reloading the file doesn't
necessarily require your application to be restarted.

If you choose the manual approach, it may not be required to access the
file asynchronously. If the file contains configuration information that
are needed to start your main application you can also use synchronous
code. There is usually no "concurrency" to handle during the startup phase
of your application.
Il 27/mag/2014 16:30 "Paul Vencill" <[email protected]> ha scritto:

> Yep, agree with Arya and Nick, using require() is the best way to do it.
> I've used it on several modules to good effect.
>
> --
> 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/a9d6ca81-30ea-43ea-b7da-7c9113ae94dc%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CABQ8R0zxdV9LbXV-L5ogxMRJR-v2N1qY%3DWu%3DTEiRMsGO0u2Z6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to