Passing vars in Node child_process.spawn call

I want to pass 2 variables to a child process to be accessed within this process. I have tried many things mentioned in SO posts but none have proved useful.

I have a Meteor method called phantom that opens the child process.

   phantom: function(firstname, lastname) {

            // Attempt 1
      	var env  = Object.create(process.env)
      	env.FIRST_NAME = firstname;
      	env.LAST_NAME = lastname;
      	console.log(env);


         // Attempt 2
        command = spawn(phantomjs.path, ['assets/app/phant.js'], {env: env});
        command.stdout.firstname = firstname;
        command.stdout.lastname = lastname;
        command.stdout.on('data',  function (data) {
          console.log('stdout: ' + data);
          data = users;
        });

Then I have the actual phant.js file that begins with

    var page = require('webpage').create();

    console.log(firstname, lastname); // Returns Undefined

If you look at my comments in the first meteor method, I tried 1. Setting the first name last name values as environment variables and 2. Setting the vars with child.stdin.[var here]. None of these worked.

To be clear, the phantom script works successfully, the only issue is with loading in the vars.

Any suggestions or help would be much appreciated.

For a working example that might help, take a look at the test suite of Meteor’s Mongo DB node driver:

  1. Spawn call made in test_all.js, to access and pass parameters to test_set_runner.js:
  1. Parameter handling in test_set_runner.js: