Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3599542
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:22:49+00:00 2026-05-18T20:22:49+00:00

Is it easy/possible to do a simple include(‘./path/to/file’) type of command in node.js? All

  • 0

Is it easy/possible to do a simple include('./path/to/file') type of command in node.js?

All I want to do is have access to local variables and run a script. How do people typically organize node.js projects that are bigger than a simple hello world? (A fully functional dynamic website)

For example I’d like to have directories like:

/models

/views

… etc

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:22:50+00:00Added an answer on May 18, 2026 at 8:22 pm

    Just do a require('./yourfile.js');

    Declare all the variables that you want outside access as global variables.
    So instead of

    var a = "hello" it will be

    GLOBAL.a="hello" or just

    a = "hello"

    This is obviously bad. You don’t want to be polluting the global scope.
    Instead the suggest method is to export your functions/variables.

    If you want the MVC pattern take a look at Geddy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it easy/possible to do a simple include('./path/to/file') type of command in node.js? All
I am coming from c# where this was easy, and possible. I have this
Is it possible/easy to create a web page which would act like a Microsoft
Short version: Is it easy/feasible/possible to program modal window in Flash (AS3)? Is there
I am getting started with ASP.NET MVC. Is it easy or even possible to
Hopefullay an easy answer but is it possible to disable outlook 2003 toast pop-up
Possible Duplicate: Create shortcut to console.log() In javascript we can easy assign functions to
Is it possible to use C/C++ code in Android? And how easy is it?
Using CoreGraphics on iOS is very easy to use, but it is possible to
I have some pages designed by someone else as simple HTML that I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.