1

In my NodeJS environment, I want to include a file that will contain some personal helper functions.

Basically I want the same behavior as PHP auto_prepend_file

It should be included automatically both in projects as well as NodeJS CLI. Ideally it shouldn't require require statement. It should just create some global variables for functions that are available everywhere.

1 Answers1

0

I'm not sure I understand you.. but do you mean the include or require_once?

they can be used so:

require_once('/path/to/file/helper_functions.php');

or

include('/path/to/file/helper_functions.php');

an example can be this:

$funcs_path = '/path/to/file/helper_functions.php'
if(file_exists ($funcs_path))
{
  require_once($funcs_path);
}

I hope this can help you

The Dude
  • 323
  • 1
  • 13
  • Ah sorry, it is my mistake. So do you want to include other files into nodeJS application.. try with this [question](http://stackoverflow.com/questions/5797852/in-node-js-how-do-i-include-functions-from-my-other-files) – The Dude Oct 17 '16 at 10:08