Using code in a module which belongs to another one

I would like to use some code in a module "A" in a module "B" but i don't know how to do it.

i would like to do:

a.js

module.exports = {
  hello : function(){
    alert('helo world');
  }
};

b.js

module.exports = {
  start : function(){
    alert(A.hello());
  }
};

main.js

A = require("a");
B = require("b");
B.start();

But i get "A is not defined".

Thanks !

Node modules all have their own scope, so you need to require A in b.js too.

var A = require('a');
module.exports = {
  start : function(){
    alert(A.hello());
  }
};