Q: Node.js External function calling So I've been using NodeJS but I have a heavy background on C and C++, and I would like to know how would I "simulate" the header effect on NodeJS.
I have the following code
foo.js
 var Discord = require("discord.js");
    var request = require('request');
    var http = require('http');
    var express = require('express');
    var util = require('./dead.js');

util.beef()

then inside the other .js file
dead.js
exports.module = {
beef: function(){ request(something) }
}

I'm trying to make use of the request variable before declared inside foo.js, but it won't work because Node says it doesn't exist (so, ok it went out of scope)


*

*Do I have to require every file I want to use in dead.js? 

*Would using require impact the performance too much?

*When is it preferable to have a long
single js file rather than have multiple ones and require in each
one


A: You need to require() every file every time you use it. 
You cannot share variables directly across files, and this is a good thing (it prevents conflicts).
require() caches everything, so there are no performance concerns.
You should not put everything in a single giant JS file; that would be hard to maintain.
