# No one should ever use NodeJS, part MMCVXII

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

I previously wrote about a very surprising bug I discovered in NodeJS/HapiJS.

But today I face a new issue: How to parallelize work in NodeJs? I discovered this fantastic library called paralleljs. It assigns work to child processes. Fantastic idea, very similar to Python. And how do I get required libs into the child process? That is very difficult. From the issues on Github:

to make things a bit more concrete, this snippet would be representative of what I want to acheive

var myLocalExports = require('../myLocalExports.js');
var _ = require('lodash');

function myDataManipulationFunction(data) {
var intermediateValue = myLocalExports.sweetFunction(data);
var otherValue = _.zip(intermediateValue, [1,2,3])
return otherValue;
}

var p = new Parallel(myDataArray, {env: myEnvVars})
.require(__dirName + '../myLocalExports.js')
.require(__dirName + '../node_modules/lodash/lodash.js')

p.map(myDataManipulationFunction) // throws error, "myLocalExports" is not defined


Which… kinda makes sense. Even if the exports from myLocalExports made it into the scope of the worker…. where exactly did I define the variable “myLocalExports”

That code example is contrived, but hopefully my question is clear. What should I be doing to require in exported modules in node? And how could I assign those modules to a variable?

Source