joyent/node — Issue #2017: "new Function('var http = require('http'); ')" cause error "require is not defined"
Author: reutopiaer
Created: 2011-11-05 04:48:43+00:00
State: open

var code = "console.log(123); var http = require('http'); console.log(typeof http);";
eval(code); // output is: 123 object

var fun = new Function(code);
fun.call(this); // output is: 123 ReferenceError: require is not defined