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
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 beGLOBAL.a="hello"or justa = "hello"This is obviously bad. You don’t want to be polluting the global scope.
Instead the suggest method is to
exportyour functions/variables.If you want the MVC pattern take a look at Geddy.